Show the last in-progress task from language servers
This commit is contained in:
parent
5157b42896
commit
7a454003fe
4 changed files with 20 additions and 7 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -5852,6 +5852,7 @@ dependencies = [
|
||||||
"postage",
|
"postage",
|
||||||
"project",
|
"project",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"smallvec",
|
||||||
"theme",
|
"theme",
|
||||||
"util",
|
"util",
|
||||||
]
|
]
|
||||||
|
|
|
@ -136,10 +136,11 @@ pub struct LanguageServerStatus {
|
||||||
pending_diagnostic_updates: isize,
|
pending_diagnostic_updates: isize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct LanguageServerProgress {
|
pub struct LanguageServerProgress {
|
||||||
pub message: Option<String>,
|
pub message: Option<String>,
|
||||||
pub percentage: Option<usize>,
|
pub percentage: Option<usize>,
|
||||||
|
pub last_update_at: Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord)]
|
#[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord)]
|
||||||
|
@ -1253,6 +1254,7 @@ impl Project {
|
||||||
percentage: report
|
percentage: report
|
||||||
.percentage
|
.percentage
|
||||||
.map(|p| p as usize),
|
.map(|p| p as usize),
|
||||||
|
last_update_at: Instant::now(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.ok();
|
.ok();
|
||||||
|
@ -1494,6 +1496,7 @@ impl Project {
|
||||||
LanguageServerProgress {
|
LanguageServerProgress {
|
||||||
message: None,
|
message: None,
|
||||||
percentage: None,
|
percentage: None,
|
||||||
|
last_update_at: Instant::now(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
@ -1541,7 +1544,9 @@ impl Project {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn language_server_statuses(&self) -> impl Iterator<Item = &LanguageServerStatus> {
|
pub fn language_server_statuses(
|
||||||
|
&self,
|
||||||
|
) -> impl DoubleEndedIterator<Item = &LanguageServerStatus> {
|
||||||
self.language_server_statuses.values()
|
self.language_server_statuses.values()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3332,6 +3337,7 @@ impl Project {
|
||||||
LanguageServerProgress {
|
LanguageServerProgress {
|
||||||
message: payload.message,
|
message: payload.message,
|
||||||
percentage: payload.percentage.map(|p| p as usize),
|
percentage: payload.percentage.map(|p| p as usize),
|
||||||
|
last_update_at: Instant::now(),
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
|
@ -24,6 +24,7 @@ futures = "0.3"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
postage = { version = "0.4.1", features = ["futures-traits"] }
|
postage = { version = "0.4.1", features = ["futures-traits"] }
|
||||||
|
smallvec = { version = "1.6", features = ["union"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
client = { path = "../client", features = ["test-support"] }
|
client = { path = "../client", features = ["test-support"] }
|
||||||
|
|
|
@ -8,6 +8,8 @@ use gpui::{
|
||||||
use language::{LanguageRegistry, LanguageServerBinaryStatus};
|
use language::{LanguageRegistry, LanguageServerBinaryStatus};
|
||||||
use postage::watch;
|
use postage::watch;
|
||||||
use project::{LanguageServerProgress, Project};
|
use project::{LanguageServerProgress, Project};
|
||||||
|
use smallvec::SmallVec;
|
||||||
|
use std::cmp::Reverse;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -90,15 +92,18 @@ impl LspStatus {
|
||||||
self.project
|
self.project
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.language_server_statuses()
|
.language_server_statuses()
|
||||||
|
.rev()
|
||||||
.filter_map(|status| {
|
.filter_map(|status| {
|
||||||
if status.pending_work.is_empty() {
|
if status.pending_work.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(
|
let mut pending_work = status
|
||||||
status.pending_work.iter().map(|(token, progress)| {
|
.pending_work
|
||||||
(status.name.as_str(), token.as_str(), progress)
|
.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()
|
.flatten()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue