Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

lsp: Handle dynamic registration of workspace diagnostic capabilities (#40095)

Piotr Osiewiczff50f489805e
diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs
index 4f21255681c..9845cce5092 100644
--- a/crates/project/src/lsp_store.rs
+++ b/crates/project/src/lsp_store.rs
@@ -11444,9 +11444,25 @@ impl LspStore {
.map(serde_json::from_value)
.transpose()?
{
+ let state = self
+ .as_local_mut()
+ .context("Expected LSP Store to be local")?
+ .language_servers
+ .get_mut(&server_id)
+ .context("Could not obtain Language Servers state")?;
server.update_capabilities(|capabilities| {
capabilities.diagnostic_provider = Some(caps);
});
+ if let LanguageServerState::Running {
+ workspace_refresh_task,
+ ..
+ } = state
+ && workspace_refresh_task.is_none()
+ {
+ *workspace_refresh_task =
+ lsp_workspace_diagnostics_refresh(server.clone(), cx)
+ }
+
notify_server_capabilities_updated(&server, cx);
}
}
@@ -11610,6 +11626,19 @@ impl LspStore {
server.update_capabilities(|capabilities| {
capabilities.diagnostic_provider = None;
});
+ let state = self
+ .as_local_mut()
+ .context("Expected LSP Store to be local")?
+ .language_servers
+ .get_mut(&server_id)
+ .context("Could not obtain Language Servers state")?;
+ if let LanguageServerState::Running {
+ workspace_refresh_task,
+ ..
+ } = state
+ {
+ _ = workspace_refresh_task.take();
+ }
notify_server_capabilities_updated(&server, cx);
}
"textDocument/documentColor" => {