fix sync did change effective caps

This commit is contained in:
Smit Barmase 2025-08-25 17:58:01 +05:30
parent 6f69765172
commit e047398756
No known key found for this signature in database
2 changed files with 15 additions and 13 deletions

View file

@ -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<TextDocumentSyncKind> = 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(|| {

View file

@ -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<Cap: EffectiveCapability>(&self) -> Cap::Value {
let static_capabilities = self.capabilities();
let dynamic_capabilities = self.dynamic_capabilities.read().clone();