Show the last in-progress task from language servers

This commit is contained in:
Antonio Scandurra 2022-03-11 09:59:13 +01:00
parent 5157b42896
commit 7a454003fe
4 changed files with 20 additions and 7 deletions

View file

@ -8,6 +8,8 @@ use gpui::{
use language::{LanguageRegistry, LanguageServerBinaryStatus};
use postage::watch;
use project::{LanguageServerProgress, Project};
use smallvec::SmallVec;
use std::cmp::Reverse;
use std::fmt::Write;
use std::sync::Arc;
@ -90,15 +92,18 @@ impl LspStatus {
self.project
.read(cx)
.language_server_statuses()
.rev()
.filter_map(|status| {
if status.pending_work.is_empty() {
None
} else {
Some(
status.pending_work.iter().map(|(token, progress)| {
(status.name.as_str(), token.as_str(), progress)
}),
)
let mut pending_work = status
.pending_work
.iter()
.map(|(token, progress)| (status.name.as_str(), token.as_str(), progress))
.collect::<SmallVec<[_; 4]>>();
pending_work.sort_by_key(|(_, _, progress)| Reverse(progress.last_update_at));
Some(pending_work)
}
})
.flatten()