project: Fix LSP TextDocumentSyncCapability dynamic registration (#36234)

Closes #36213

Use `textDocument/didChange`
([docs](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_synchronization))
instead of `textDocument/synchronization`.

Release Notes:

- Fixed an issue where Dart projects were being formatted incorrectly by
the language server.
This commit is contained in:
smit 2025-08-15 16:24:54 +05:30 committed by GitHub
parent 2a57b160b0
commit f8b0105258
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11817,14 +11817,16 @@ impl LspStore {
notify_server_capabilities_updated(&server, cx);
}
}
"textDocument/synchronization" => {
if let Some(caps) = reg
"textDocument/didChange" => {
if let Some(sync_kind) = reg
.register_options
.map(serde_json::from_value)
.and_then(|opts| opts.get("syncKind").cloned())
.map(serde_json::from_value::<lsp::TextDocumentSyncKind>)
.transpose()?
{
server.update_capabilities(|capabilities| {
capabilities.text_document_sync = Some(caps);
capabilities.text_document_sync =
Some(lsp::TextDocumentSyncCapability::Kind(sync_kind));
});
notify_server_capabilities_updated(&server, cx);
}
@ -11974,7 +11976,7 @@ impl LspStore {
});
notify_server_capabilities_updated(&server, cx);
}
"textDocument/synchronization" => {
"textDocument/didChange" => {
server.update_capabilities(|capabilities| {
capabilities.text_document_sync = None;
});