From 96a917091a80c0430b6b7d816d747e3bbf14f533 Mon Sep 17 00:00:00 2001 From: Andrew Farkas <6060305+HactarCE@users.noreply.github.com> Date: Tue, 2 Dec 2025 16:33:41 -0500 Subject: [PATCH] Apply `show_completions_on_input: false` to word & snippet completions (#44021) Closes #43408 Previously, we checked the setting inside `is_completion_trigger()`, which only affects LSP completions. This was ok because user-defined snippets were tacked onto LSP completions. Then #42122 and #42398 made snippet completions their own thing, similar to word completions, surfacing #43408. This PR moves the settings check into `open_or_update_completions_menu()` so it applies to all completions. Release Notes: - Fixed setting `show_completions_on_input: false` so that it affects word and user-defined snippet completions as well as LSP completions --- crates/agent_ui/src/completion_provider.rs | 1 - crates/agent_ui/src/slash_command.rs | 1 - .../src/session/running/console.rs | 4 -- crates/editor/src/editor.rs | 40 +++++++++---------- crates/inspector_ui/src/div_inspector.rs | 1 - crates/keymap_editor/src/keymap_editor.rs | 1 - 6 files changed, 18 insertions(+), 30 deletions(-) diff --git a/crates/agent_ui/src/completion_provider.rs b/crates/agent_ui/src/completion_provider.rs index 2e3cf0d551fc649e61ae26e47fa53301def2aacc..a2b6e0510e25c12cfbfb98d3e72cb0d2c830887a 100644 --- a/crates/agent_ui/src/completion_provider.rs +++ b/crates/agent_ui/src/completion_provider.rs @@ -1114,7 +1114,6 @@ impl CompletionProvider for PromptCompletio position: language::Anchor, _text: &str, _trigger_in_words: bool, - _menu_is_open: bool, cx: &mut Context, ) -> bool { let buffer = buffer.read(cx); diff --git a/crates/agent_ui/src/slash_command.rs b/crates/agent_ui/src/slash_command.rs index 7d3ea0105a0aafb4cfccf4076cb95e28c99dec28..e328ef6725e5e789bd402667da91417ad69a372d 100644 --- a/crates/agent_ui/src/slash_command.rs +++ b/crates/agent_ui/src/slash_command.rs @@ -341,7 +341,6 @@ impl CompletionProvider for SlashCommandCompletionProvider { position: language::Anchor, _text: &str, _trigger_in_words: bool, - _menu_is_open: bool, cx: &mut Context, ) -> bool { let buffer = buffer.read(cx); diff --git a/crates/debugger_ui/src/session/running/console.rs b/crates/debugger_ui/src/session/running/console.rs index 717169ff5ad1d0f479075ca996c550a774a4307a..d20108b61205bacd3ea09af0ea34fabbec621c20 100644 --- a/crates/debugger_ui/src/session/running/console.rs +++ b/crates/debugger_ui/src/session/running/console.rs @@ -559,7 +559,6 @@ impl CompletionProvider for ConsoleQueryBarCompletionProvider { position: language::Anchor, text: &str, trigger_in_words: bool, - menu_is_open: bool, cx: &mut Context, ) -> bool { let mut chars = text.chars(); @@ -570,9 +569,6 @@ impl CompletionProvider for ConsoleQueryBarCompletionProvider { }; let snapshot = buffer.read(cx).snapshot(); - if !menu_is_open && !snapshot.settings_at(position, cx).show_completions_on_input { - return false; - } let classifier = snapshot .char_classifier_at(position) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 114dbac23e80814c64471d7123ef73a29ccfc115..babedf1e0829bb1105b2c9c3787d98aa662eedde 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5509,6 +5509,22 @@ impl Editor { }; let buffer_snapshot = buffer.read(cx).snapshot(); + let menu_is_open = matches!( + self.context_menu.borrow().as_ref(), + Some(CodeContextMenu::Completions(_)) + ); + + let language = buffer_snapshot + .language_at(buffer_position.text_anchor) + .map(|language| language.name()); + + let language_settings = language_settings(language.clone(), buffer_snapshot.file(), cx); + let completion_settings = language_settings.completions.clone(); + + if !menu_is_open && trigger.is_some() && !language_settings.show_completions_on_input { + return; + } + let query: Option> = Self::completion_query(&multibuffer_snapshot, buffer_position) .map(|query| query.into()); @@ -5517,14 +5533,8 @@ impl Editor { // Hide the current completions menu when query is empty. Without this, cached // completions from before the trigger char may be reused (#32774). - if query.is_none() { - let menu_is_open = matches!( - self.context_menu.borrow().as_ref(), - Some(CodeContextMenu::Completions(_)) - ); - if menu_is_open { - self.hide_context_menu(window, cx); - } + if query.is_none() && menu_is_open { + self.hide_context_menu(window, cx); } let mut ignore_word_threshold = false; @@ -5613,14 +5623,6 @@ impl Editor { (buffer_position..buffer_position, None) }; - let language = buffer_snapshot - .language_at(buffer_position) - .map(|language| language.name()); - - let completion_settings = language_settings(language.clone(), buffer_snapshot.file(), cx) - .completions - .clone(); - let show_completion_documentation = buffer_snapshot .settings_at(buffer_position, cx) .show_completion_documentation; @@ -5651,7 +5653,6 @@ impl Editor { position.text_anchor, trigger, trigger_in_words, - completions_source.is_some(), cx, ) }) @@ -23486,7 +23487,6 @@ pub trait CompletionProvider { position: language::Anchor, text: &str, trigger_in_words: bool, - menu_is_open: bool, cx: &mut Context, ) -> bool; @@ -23865,7 +23865,6 @@ impl CompletionProvider for Entity { position: language::Anchor, text: &str, trigger_in_words: bool, - menu_is_open: bool, cx: &mut Context, ) -> bool { let mut chars = text.chars(); @@ -23880,9 +23879,6 @@ impl CompletionProvider for Entity { let buffer = buffer.read(cx); let snapshot = buffer.snapshot(); - if !menu_is_open && !snapshot.settings_at(position, cx).show_completions_on_input { - return false; - } let classifier = snapshot .char_classifier_at(position) .scope_context(Some(CharScopeContext::Completion)); diff --git a/crates/inspector_ui/src/div_inspector.rs b/crates/inspector_ui/src/div_inspector.rs index 35a5d2786f8d044dd9c41a3a4605538ea8f37c37..9b145e920e48605f19f566ca14a7caf63aff8f0a 100644 --- a/crates/inspector_ui/src/div_inspector.rs +++ b/crates/inspector_ui/src/div_inspector.rs @@ -686,7 +686,6 @@ impl CompletionProvider for RustStyleCompletionProvider { position: language::Anchor, _text: &str, _trigger_in_words: bool, - _menu_is_open: bool, cx: &mut Context, ) -> bool { completion_replace_range(&buffer.read(cx).snapshot(), &position).is_some() diff --git a/crates/keymap_editor/src/keymap_editor.rs b/crates/keymap_editor/src/keymap_editor.rs index ce78a1d60ac610bbf10383377fef667c0a4eaa36..113d5026eb89587714172ff4c76698bcadb5fd6a 100644 --- a/crates/keymap_editor/src/keymap_editor.rs +++ b/crates/keymap_editor/src/keymap_editor.rs @@ -3001,7 +3001,6 @@ impl CompletionProvider for KeyContextCompletionProvider { _position: language::Anchor, text: &str, _trigger_in_words: bool, - _menu_is_open: bool, _cx: &mut Context, ) -> bool { text.chars()