fix sync did change effective caps
This commit is contained in:
parent
6f69765172
commit
e047398756
2 changed files with 15 additions and 13 deletions
|
@ -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;
|
||||
}
|
||||
best
|
||||
let mut has_incremental = false;
|
||||
for &kind in id_to_sync_kind_map.values() {
|
||||
if kind == TextDocumentSyncKind::FULL {
|
||||
return Some(TextDocumentSyncKind::FULL);
|
||||
}
|
||||
if kind == TextDocumentSyncKind::INCREMENTAL {
|
||||
has_incremental = true;
|
||||
}
|
||||
}
|
||||
if has_incremental {
|
||||
Some(TextDocumentSyncKind::INCREMENTAL)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.or_else(|| {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue