From f91fdd2ba0072d1a98e479fed3d0afb8d1ec4229 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 22 Apr 2022 15:43:23 +0200 Subject: [PATCH] Return `None` when prepare rename is not available on language server --- crates/lsp/src/lsp.rs | 4 ++++ crates/project/src/lsp_command.rs | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rs index c0b21eeeda..02bc0486f1 100644 --- a/crates/lsp/src/lsp.rs +++ b/crates/lsp/src/lsp.rs @@ -292,6 +292,10 @@ impl LanguageServer { }), ..Default::default() }), + rename: Some(RenameClientCapabilities { + prepare_support: Some(true), + ..Default::default() + }), ..Default::default() }), experimental: Some(json!({ diff --git a/crates/project/src/lsp_command.rs b/crates/project/src/lsp_command.rs index 71ad489d07..1e86bb2719 100644 --- a/crates/project/src/lsp_command.rs +++ b/crates/project/src/lsp_command.rs @@ -86,6 +86,14 @@ impl LspCommand for PrepareRename { type LspRequest = lsp::request::PrepareRenameRequest; type ProtoRequest = proto::PrepareRename; + fn check_capabilities(&self, capabilities: &ServerCapabilities) -> bool { + if let Some(lsp::OneOf::Right(rename)) = &capabilities.rename_provider { + rename.prepare_provider == Some(true) + } else { + false + } + } + fn to_lsp(&self, path: &Path, _: &AppContext) -> lsp::TextDocumentPositionParams { lsp::TextDocumentPositionParams { text_document: lsp::TextDocumentIdentifier {