aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp/src
diff options
context:
space:
mode:
authormisiasty32023-03-13 15:29:23 +0000
committerGitHub2023-03-13 15:29:23 +0000
commitdb8e9f5bb2e2b9412cb1cc4688ad2febb726e48c (patch)
tree82a93e8720ea6fc2b441e7ec07a7335a5270e0a0 /helix-lsp/src
parentdc418bb50739c8063978f4200fcd9fcae73db002 (diff)
Check language server symbol renaming support before prompting (#6257)
Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
Diffstat (limited to 'helix-lsp/src')
-rw-r--r--helix-lsp/src/client.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index 9cb7c147..c46bdd8c 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -1136,20 +1136,23 @@ impl Client {
Some(self.call::<lsp::request::CodeActionRequest>(params))
}
+ pub fn supports_rename(&self) -> bool {
+ let capabilities = self.capabilities.get().unwrap();
+ matches!(
+ capabilities.rename_provider,
+ Some(lsp::OneOf::Left(true) | lsp::OneOf::Right(_))
+ )
+ }
+
pub fn rename_symbol(
&self,
text_document: lsp::TextDocumentIdentifier,
position: lsp::Position,
new_name: String,
) -> Option<impl Future<Output = Result<lsp::WorkspaceEdit>>> {
- let capabilities = self.capabilities.get().unwrap();
-
- // Return early if the language server does not support renaming.
- match capabilities.rename_provider {
- Some(lsp::OneOf::Left(true)) | Some(lsp::OneOf::Right(_)) => (),
- // None | Some(false)
- _ => return None,
- };
+ if !self.supports_rename() {
+ return None;
+ }
let params = lsp::RenameParams {
text_document_position: lsp::TextDocumentPositionParams {