mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
Fix unregistration logic for pull diagnostics (#44294)
Even if `workspace_diagnostics_refresh_tasks` is empty, registrations which didn't advertise support for workspace diagnostics may still exist. Release Notes: - N/A
This commit is contained in:
parent
a0848daab4
commit
9e33243015
1 changed files with 5 additions and 6 deletions
|
|
@ -12647,30 +12647,29 @@ impl LspStore {
|
|||
.language_servers
|
||||
.get_mut(&server_id)
|
||||
.context("Could not obtain Language Servers state")?;
|
||||
local
|
||||
let registrations = local
|
||||
.language_server_dynamic_registrations
|
||||
.get_mut(&server_id)
|
||||
.with_context(|| {
|
||||
format!("Expected dynamic registration to exist for server {server_id}")
|
||||
})?.diagnostics
|
||||
})?;
|
||||
registrations.diagnostics
|
||||
.remove(&Some(unreg.id.clone()))
|
||||
.with_context(|| format!(
|
||||
"Attempted to unregister non-existent diagnostic registration with ID {}",
|
||||
unreg.id)
|
||||
)?;
|
||||
let removed_last_diagnostic_provider = registrations.diagnostics.is_empty();
|
||||
|
||||
let mut has_any_diagnostic_providers_still = true;
|
||||
if let LanguageServerState::Running {
|
||||
workspace_diagnostics_refresh_tasks,
|
||||
..
|
||||
} = state
|
||||
{
|
||||
workspace_diagnostics_refresh_tasks.remove(&Some(unreg.id.clone()));
|
||||
has_any_diagnostic_providers_still =
|
||||
!workspace_diagnostics_refresh_tasks.is_empty();
|
||||
}
|
||||
|
||||
if !has_any_diagnostic_providers_still {
|
||||
if removed_last_diagnostic_provider {
|
||||
server.update_capabilities(|capabilities| {
|
||||
debug_assert!(capabilities.diagnostic_provider.is_some());
|
||||
capabilities.diagnostic_provider = None;
|
||||
|
|
|
|||
Loading…
Reference in a new issue