mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-26 03:59:55 +00:00
Handle messages associated with LSP WorkDoneProgress::Begin
messages
Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
a41f164ffe
commit
36ce3eb5ef
2 changed files with 56 additions and 12 deletions
|
@ -1927,6 +1927,20 @@ impl Project {
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
|
// Even though we don't have handling for these requests, respond to them to
|
||||||
|
// avoid stalling any language server like `gopls` which waits for a response
|
||||||
|
// to these requests when initializing.
|
||||||
|
language_server
|
||||||
|
.on_request::<lsp::request::WorkDoneProgressCreate, _, _>(|_, _| async {
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
language_server
|
||||||
|
.on_request::<lsp::request::RegisterCapability, _, _>(|_, _| async {
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
|
||||||
language_server
|
language_server
|
||||||
.on_request::<lsp::request::ApplyWorkspaceEdit, _, _>({
|
.on_request::<lsp::request::ApplyWorkspaceEdit, _, _>({
|
||||||
let this = this.downgrade();
|
let this = this.downgrade();
|
||||||
|
@ -2159,7 +2173,7 @@ impl Project {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
match progress {
|
match progress {
|
||||||
lsp::WorkDoneProgress::Begin(_) => {
|
lsp::WorkDoneProgress::Begin(report) => {
|
||||||
if Some(token.as_str()) == disk_based_diagnostics_progress_token {
|
if Some(token.as_str()) == disk_based_diagnostics_progress_token {
|
||||||
language_server_status.pending_diagnostic_updates += 1;
|
language_server_status.pending_diagnostic_updates += 1;
|
||||||
if language_server_status.pending_diagnostic_updates == 1 {
|
if language_server_status.pending_diagnostic_updates == 1 {
|
||||||
|
@ -2172,11 +2186,22 @@ impl Project {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.on_lsp_work_start(server_id, token.clone(), cx);
|
self.on_lsp_work_start(
|
||||||
|
server_id,
|
||||||
|
token.clone(),
|
||||||
|
LanguageServerProgress {
|
||||||
|
message: report.message.clone(),
|
||||||
|
percentage: report.percentage.map(|p| p as usize),
|
||||||
|
last_update_at: Instant::now(),
|
||||||
|
},
|
||||||
|
cx,
|
||||||
|
);
|
||||||
self.broadcast_language_server_update(
|
self.broadcast_language_server_update(
|
||||||
server_id,
|
server_id,
|
||||||
proto::update_language_server::Variant::WorkStart(proto::LspWorkStart {
|
proto::update_language_server::Variant::WorkStart(proto::LspWorkStart {
|
||||||
token,
|
token,
|
||||||
|
message: report.message,
|
||||||
|
percentage: report.percentage.map(|p| p as u32),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2234,17 +2259,11 @@ impl Project {
|
||||||
&mut self,
|
&mut self,
|
||||||
language_server_id: usize,
|
language_server_id: usize,
|
||||||
token: String,
|
token: String,
|
||||||
|
progress: LanguageServerProgress,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) {
|
) {
|
||||||
if let Some(status) = self.language_server_statuses.get_mut(&language_server_id) {
|
if let Some(status) = self.language_server_statuses.get_mut(&language_server_id) {
|
||||||
status.pending_work.insert(
|
status.pending_work.insert(token, progress);
|
||||||
token,
|
|
||||||
LanguageServerProgress {
|
|
||||||
message: None,
|
|
||||||
percentage: None,
|
|
||||||
last_update_at: Instant::now(),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2257,7 +2276,21 @@ impl Project {
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) {
|
) {
|
||||||
if let Some(status) = self.language_server_statuses.get_mut(&language_server_id) {
|
if let Some(status) = self.language_server_statuses.get_mut(&language_server_id) {
|
||||||
status.pending_work.insert(token, progress);
|
let entry = status
|
||||||
|
.pending_work
|
||||||
|
.entry(token)
|
||||||
|
.or_insert(LanguageServerProgress {
|
||||||
|
message: Default::default(),
|
||||||
|
percentage: Default::default(),
|
||||||
|
last_update_at: progress.last_update_at,
|
||||||
|
});
|
||||||
|
if progress.message.is_some() {
|
||||||
|
entry.message = progress.message;
|
||||||
|
}
|
||||||
|
if progress.percentage.is_some() {
|
||||||
|
entry.percentage = progress.percentage;
|
||||||
|
}
|
||||||
|
entry.last_update_at = progress.last_update_at;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4472,7 +4505,16 @@ impl Project {
|
||||||
{
|
{
|
||||||
proto::update_language_server::Variant::WorkStart(payload) => {
|
proto::update_language_server::Variant::WorkStart(payload) => {
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.on_lsp_work_start(language_server_id, payload.token, cx);
|
this.on_lsp_work_start(
|
||||||
|
language_server_id,
|
||||||
|
payload.token,
|
||||||
|
LanguageServerProgress {
|
||||||
|
message: payload.message,
|
||||||
|
percentage: payload.percentage.map(|p| p as usize),
|
||||||
|
last_update_at: Instant::now(),
|
||||||
|
},
|
||||||
|
cx,
|
||||||
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
proto::update_language_server::Variant::WorkProgress(payload) => {
|
proto::update_language_server::Variant::WorkProgress(payload) => {
|
||||||
|
|
|
@ -555,6 +555,8 @@ message UpdateLanguageServer {
|
||||||
|
|
||||||
message LspWorkStart {
|
message LspWorkStart {
|
||||||
string token = 1;
|
string token = 1;
|
||||||
|
optional string message = 2;
|
||||||
|
optional uint32 percentage = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message LspWorkProgress {
|
message LspWorkProgress {
|
||||||
|
|
Loading…
Reference in a new issue