From 39b1466cb8225c8dbd2df44497debbb13aa5e140 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 5 Jan 2024 14:51:50 -0500 Subject: [PATCH] Check for rename support before showing rename prompt Previously we always showed the prompt even if the current document didn't have a language server that could perform a rename. For example we showed a rename prompt even when using `r` in a scratch buffer. Instead we should check the document's language servers to see if any supports a rename and bail if there are none. --- helix-term/src/commands/lsp.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index ac6a1a2134cf..34ffa529c6a4 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -1421,6 +1421,16 @@ pub fn rename_symbol(cx: &mut Context) { let (view, doc) = current_ref!(cx.editor); + if doc + .language_servers_with_feature(LanguageServerFeature::RenameSymbol) + .next() + .is_none() + { + cx.editor + .set_error("No configured language server supports symbol renaming"); + return; + } + let language_server_with_prepare_rename_support = doc .language_servers_with_feature(LanguageServerFeature::RenameSymbol) .find(|ls| {