Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Apply `show_completions_on_input: false` to word & snippet completions (#44021)
Andrew Farkas96a917091a80
diff --git a/crates/agent_ui/src/completion_provider.rs b/crates/agent_ui/src/completion_provider.rsindex 2e3cf0d551f..a2b6e0510e2 100644--- a/crates/agent_ui/src/completion_provider.rs+++ b/crates/agent_ui/src/completion_provider.rs@@ -1114,7 +1114,6 @@ impl<T: PromptCompletionProviderDelegate> CompletionProvider for PromptCompletioposition: language::Anchor,_text: &str,_trigger_in_words: bool,- _menu_is_open: bool,cx: &mut Context<Editor>,) -> bool {let buffer = buffer.read(cx);diff --git a/crates/agent_ui/src/slash_command.rs b/crates/agent_ui/src/slash_command.rsindex 7d3ea0105a0..e328ef6725e 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<Editor>,) -> 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.rsindex 717169ff5ad..d20108b6120 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<Editor>,) -> 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.rsindex 114dbac23e8..babedf1e082 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<Arc<String>> =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<Editor>,) -> bool;@@ -23865,7 +23865,6 @@ impl CompletionProvider for Entity<Project> {position: language::Anchor,text: &str,trigger_in_words: bool,- menu_is_open: bool,cx: &mut Context<Editor>,) -> bool {let mut chars = text.chars();@@ -23880,9 +23879,6 @@ impl CompletionProvider for Entity<Project> {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.rsindex 35a5d2786f8..9b145e920e4 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<Editor>,) -> 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.rsindex ce78a1d60ac..113d5026eb8 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<Editor>,) -> bool {text.chars()