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
This commit is contained in:
@@ -1114,7 +1114,6 @@ impl<T: PromptCompletionProviderDelegate> CompletionProvider for PromptCompletio
|
||||
position: language::Anchor,
|
||||
_text: &str,
|
||||
_trigger_in_words: bool,
|
||||
_menu_is_open: bool,
|
||||
cx: &mut Context<Editor>,
|
||||
) -> bool {
|
||||
let buffer = buffer.read(cx);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
+18
-22
@@ -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));
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user