From e047398756d9a6d4a4112f7e70fefa015120797f Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Mon, 25 Aug 2025 17:58:01 +0530 Subject: [PATCH] fix sync did change effective caps --- crates/lsp/src/capabilities.rs | 27 ++++++++++++++------------- crates/lsp/src/lsp.rs | 1 + 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/crates/lsp/src/capabilities.rs b/crates/lsp/src/capabilities.rs index d8026df027..ae803e4269 100644 --- a/crates/lsp/src/capabilities.rs +++ b/crates/lsp/src/capabilities.rs @@ -27,20 +27,21 @@ impl EffectiveCapability for cap::DidChangeTextDocument { .as_ref() .and_then(|id_to_sync_kind_map| { if id_to_sync_kind_map.is_empty() { - None - } else { - let mut best: Option = None; - for kind in id_to_sync_kind_map.values() { - best = Some(match (best, kind) { - (None, kind) => *kind, - ( - Some(TextDocumentSyncKind::FULL), - &TextDocumentSyncKind::INCREMENTAL, - ) => TextDocumentSyncKind::INCREMENTAL, - (Some(kind), _) => kind, - }); + return None; + } + let mut has_incremental = false; + for &kind in id_to_sync_kind_map.values() { + if kind == TextDocumentSyncKind::FULL { + return Some(TextDocumentSyncKind::FULL); } - best + if kind == TextDocumentSyncKind::INCREMENTAL { + has_incremental = true; + } + } + if has_incremental { + Some(TextDocumentSyncKind::INCREMENTAL) + } else { + None } }) .or_else(|| { diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index 9c2eb02120..13990d4533 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -1148,6 +1148,7 @@ impl LanguageServer { update(self.dynamic_capabilities.write().deref_mut()); } + /// Get effective capabilities by combining static and dynamic capabilities. pub fn effective_capability(&self) -> Cap::Value { let static_capabilities = self.capabilities(); let dynamic_capabilities = self.dynamic_capabilities.read().clone();