Tweak word completions more (#37697)
Follow-up of https://github.com/zed-industries/zed/pull/37352 Closes https://github.com/zed-industries/zed/issues/37132 * disabled word completions in the agent panel's editor * if not disabled, allow to trigger word completions with an action even if the completions threshold is not reached Release Notes: - Fixed word completions appearing in the agent panel's editor and not appearing when triggered with the action before the completion threshold is reached
This commit is contained in:
@@ -1030,6 +1030,7 @@ pub struct Editor {
|
||||
inline_diagnostics_update: Task<()>,
|
||||
inline_diagnostics_enabled: bool,
|
||||
diagnostics_enabled: bool,
|
||||
word_completions_enabled: bool,
|
||||
inline_diagnostics: Vec<(Anchor, InlineDiagnostic)>,
|
||||
soft_wrap_mode_override: Option<language_settings::SoftWrap>,
|
||||
hard_wrap: Option<usize>,
|
||||
@@ -2163,6 +2164,7 @@ impl Editor {
|
||||
},
|
||||
inline_diagnostics_enabled: full_mode,
|
||||
diagnostics_enabled: full_mode,
|
||||
word_completions_enabled: full_mode,
|
||||
inline_value_cache: InlineValueCache::new(inlay_hint_settings.show_value_hints),
|
||||
inlay_hint_cache: InlayHintCache::new(inlay_hint_settings),
|
||||
gutter_hovered: false,
|
||||
@@ -4892,8 +4894,15 @@ impl Editor {
|
||||
});
|
||||
|
||||
match completions_source {
|
||||
Some(CompletionsMenuSource::Words) => {
|
||||
self.show_word_completions(&ShowWordCompletions, window, cx)
|
||||
Some(CompletionsMenuSource::Words { .. }) => {
|
||||
self.open_or_update_completions_menu(
|
||||
Some(CompletionsMenuSource::Words {
|
||||
ignore_threshold: false,
|
||||
}),
|
||||
None,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
Some(CompletionsMenuSource::Normal)
|
||||
| Some(CompletionsMenuSource::SnippetChoices)
|
||||
@@ -5401,7 +5410,14 @@ impl Editor {
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.open_or_update_completions_menu(Some(CompletionsMenuSource::Words), None, window, cx);
|
||||
self.open_or_update_completions_menu(
|
||||
Some(CompletionsMenuSource::Words {
|
||||
ignore_threshold: true,
|
||||
}),
|
||||
None,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn show_completions(
|
||||
@@ -5450,9 +5466,13 @@ impl Editor {
|
||||
|
||||
drop(multibuffer_snapshot);
|
||||
|
||||
let mut ignore_word_threshold = false;
|
||||
let provider = match requested_source {
|
||||
Some(CompletionsMenuSource::Normal) | None => self.completion_provider.clone(),
|
||||
Some(CompletionsMenuSource::Words) => None,
|
||||
Some(CompletionsMenuSource::Words { ignore_threshold }) => {
|
||||
ignore_word_threshold = ignore_threshold;
|
||||
None
|
||||
}
|
||||
Some(CompletionsMenuSource::SnippetChoices) => {
|
||||
log::error!("bug: SnippetChoices requested_source is not handled");
|
||||
None
|
||||
@@ -5573,10 +5593,12 @@ impl Editor {
|
||||
.as_ref()
|
||||
.is_none_or(|query| !query.chars().any(|c| c.is_digit(10)));
|
||||
|
||||
let omit_word_completions = match &query {
|
||||
Some(query) => query.chars().count() < completion_settings.words_min_length,
|
||||
None => completion_settings.words_min_length != 0,
|
||||
};
|
||||
let omit_word_completions = !self.word_completions_enabled
|
||||
|| (!ignore_word_threshold
|
||||
&& match &query {
|
||||
Some(query) => query.chars().count() < completion_settings.words_min_length,
|
||||
None => completion_settings.words_min_length != 0,
|
||||
});
|
||||
|
||||
let (mut words, provider_responses) = match &provider {
|
||||
Some(provider) => {
|
||||
@@ -17121,6 +17143,10 @@ impl Editor {
|
||||
self.inline_diagnostics.clear();
|
||||
}
|
||||
|
||||
pub fn disable_word_completions(&mut self) {
|
||||
self.word_completions_enabled = false;
|
||||
}
|
||||
|
||||
pub fn diagnostics_enabled(&self) -> bool {
|
||||
self.diagnostics_enabled && self.mode.is_full()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user