Revert "project: Handle textDocument/didSave
and textDocument/didChange
(un)registration and usage correctly (#36441)" (#36480)
This reverts commit c5991e74bb
.
This PR broke rust-analyzer's check on save function, so reverting for
now
Release Notes:
- N/A
This commit is contained in:
parent
2fb89c9b3e
commit
9e8ec72bd5
2 changed files with 17 additions and 57 deletions
|
@ -827,7 +827,7 @@ impl LanguageServer {
|
||||||
}),
|
}),
|
||||||
synchronization: Some(TextDocumentSyncClientCapabilities {
|
synchronization: Some(TextDocumentSyncClientCapabilities {
|
||||||
did_save: Some(true),
|
did_save: Some(true),
|
||||||
dynamic_registration: Some(true),
|
dynamic_registration: Some(false),
|
||||||
..TextDocumentSyncClientCapabilities::default()
|
..TextDocumentSyncClientCapabilities::default()
|
||||||
}),
|
}),
|
||||||
code_lens: Some(CodeLensClientCapabilities {
|
code_lens: Some(CodeLensClientCapabilities {
|
||||||
|
|
|
@ -11820,28 +11820,8 @@ impl LspStore {
|
||||||
.transpose()?
|
.transpose()?
|
||||||
{
|
{
|
||||||
server.update_capabilities(|capabilities| {
|
server.update_capabilities(|capabilities| {
|
||||||
let mut sync_options =
|
|
||||||
Self::take_text_document_sync_options(capabilities);
|
|
||||||
sync_options.change = Some(sync_kind);
|
|
||||||
capabilities.text_document_sync =
|
capabilities.text_document_sync =
|
||||||
Some(lsp::TextDocumentSyncCapability::Options(sync_options));
|
Some(lsp::TextDocumentSyncCapability::Kind(sync_kind));
|
||||||
});
|
|
||||||
notify_server_capabilities_updated(&server, cx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"textDocument/didSave" => {
|
|
||||||
if let Some(save_options) = reg
|
|
||||||
.register_options
|
|
||||||
.and_then(|opts| opts.get("includeText").cloned())
|
|
||||||
.map(serde_json::from_value::<lsp::TextDocumentSyncSaveOptions>)
|
|
||||||
.transpose()?
|
|
||||||
{
|
|
||||||
server.update_capabilities(|capabilities| {
|
|
||||||
let mut sync_options =
|
|
||||||
Self::take_text_document_sync_options(capabilities);
|
|
||||||
sync_options.save = Some(save_options);
|
|
||||||
capabilities.text_document_sync =
|
|
||||||
Some(lsp::TextDocumentSyncCapability::Options(sync_options));
|
|
||||||
});
|
});
|
||||||
notify_server_capabilities_updated(&server, cx);
|
notify_server_capabilities_updated(&server, cx);
|
||||||
}
|
}
|
||||||
|
@ -11993,19 +11973,7 @@ impl LspStore {
|
||||||
}
|
}
|
||||||
"textDocument/didChange" => {
|
"textDocument/didChange" => {
|
||||||
server.update_capabilities(|capabilities| {
|
server.update_capabilities(|capabilities| {
|
||||||
let mut sync_options = Self::take_text_document_sync_options(capabilities);
|
capabilities.text_document_sync = None;
|
||||||
sync_options.change = None;
|
|
||||||
capabilities.text_document_sync =
|
|
||||||
Some(lsp::TextDocumentSyncCapability::Options(sync_options));
|
|
||||||
});
|
|
||||||
notify_server_capabilities_updated(&server, cx);
|
|
||||||
}
|
|
||||||
"textDocument/didSave" => {
|
|
||||||
server.update_capabilities(|capabilities| {
|
|
||||||
let mut sync_options = Self::take_text_document_sync_options(capabilities);
|
|
||||||
sync_options.save = None;
|
|
||||||
capabilities.text_document_sync =
|
|
||||||
Some(lsp::TextDocumentSyncCapability::Options(sync_options));
|
|
||||||
});
|
});
|
||||||
notify_server_capabilities_updated(&server, cx);
|
notify_server_capabilities_updated(&server, cx);
|
||||||
}
|
}
|
||||||
|
@ -12033,20 +12001,6 @@ impl LspStore {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take_text_document_sync_options(
|
|
||||||
capabilities: &mut lsp::ServerCapabilities,
|
|
||||||
) -> lsp::TextDocumentSyncOptions {
|
|
||||||
match capabilities.text_document_sync.take() {
|
|
||||||
Some(lsp::TextDocumentSyncCapability::Options(sync_options)) => sync_options,
|
|
||||||
Some(lsp::TextDocumentSyncCapability::Kind(sync_kind)) => {
|
|
||||||
let mut sync_options = lsp::TextDocumentSyncOptions::default();
|
|
||||||
sync_options.change = Some(sync_kind);
|
|
||||||
sync_options
|
|
||||||
}
|
|
||||||
None => lsp::TextDocumentSyncOptions::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Registration with empty capabilities should be ignored.
|
// Registration with empty capabilities should be ignored.
|
||||||
|
@ -13149,18 +13103,24 @@ async fn populate_labels_for_symbols(
|
||||||
|
|
||||||
fn include_text(server: &lsp::LanguageServer) -> Option<bool> {
|
fn include_text(server: &lsp::LanguageServer) -> Option<bool> {
|
||||||
match server.capabilities().text_document_sync.as_ref()? {
|
match server.capabilities().text_document_sync.as_ref()? {
|
||||||
lsp::TextDocumentSyncCapability::Options(opts) => match opts.save.as_ref()? {
|
lsp::TextDocumentSyncCapability::Kind(kind) => match *kind {
|
||||||
// Server wants didSave but didn't specify includeText.
|
lsp::TextDocumentSyncKind::NONE => None,
|
||||||
lsp::TextDocumentSyncSaveOptions::Supported(true) => Some(false),
|
lsp::TextDocumentSyncKind::FULL => Some(true),
|
||||||
// Server doesn't want didSave at all.
|
lsp::TextDocumentSyncKind::INCREMENTAL => Some(false),
|
||||||
lsp::TextDocumentSyncSaveOptions::Supported(false) => None,
|
_ => None,
|
||||||
// Server provided SaveOptions.
|
},
|
||||||
|
lsp::TextDocumentSyncCapability::Options(options) => match options.save.as_ref()? {
|
||||||
|
lsp::TextDocumentSyncSaveOptions::Supported(supported) => {
|
||||||
|
if *supported {
|
||||||
|
Some(true)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
lsp::TextDocumentSyncSaveOptions::SaveOptions(save_options) => {
|
lsp::TextDocumentSyncSaveOptions::SaveOptions(save_options) => {
|
||||||
Some(save_options.include_text.unwrap_or(false))
|
Some(save_options.include_text.unwrap_or(false))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// We do not have any save info. Kind affects didChange only.
|
|
||||||
lsp::TextDocumentSyncCapability::Kind(_) => None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue