From 966533624a582f6270d6423b665b59d109c5463f Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Thu, 23 Jan 2025 18:49:17 -0300 Subject: [PATCH] Disable zeta predictions in assistant completion menu (#23573) We don't want the zeta predictions entry to show in the assistant context editor when completing slash commands. Zeta will still make suggestions in the rest of the context editor, like the other providers do. Release Notes: - N/A --- .../src/context_editor.rs | 5 +++-- crates/editor/src/editor.rs | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/assistant_context_editor/src/context_editor.rs b/crates/assistant_context_editor/src/context_editor.rs index be758115c3..7f4b27057f 100644 --- a/crates/assistant_context_editor/src/context_editor.rs +++ b/crates/assistant_context_editor/src/context_editor.rs @@ -15,8 +15,8 @@ use editor::{ CustomBlockId, FoldId, RenderBlock, ToDisplayPoint, }, scroll::{Autoscroll, AutoscrollStrategy}, - Anchor, Editor, EditorEvent, ProposedChangeLocation, ProposedChangesEditor, RowExt, - ToOffset as _, ToPoint, + Anchor, Editor, EditorEvent, MenuInlineCompletionsPolicy, ProposedChangeLocation, + ProposedChangesEditor, RowExt, ToOffset as _, ToPoint, }; use editor::{display_map::CreaseId, FoldPlaceholder}; use fs::Fs; @@ -220,6 +220,7 @@ impl ContextEditor { editor.set_show_wrap_guides(false, cx); editor.set_show_indent_guides(false, cx); editor.set_completion_provider(Some(Box::new(completion_provider))); + editor.set_menu_inline_completions_policy(MenuInlineCompletionsPolicy::Never); editor.set_collaboration_hub(Box::new(project.clone())); editor }); diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index cf8640e048..5e09f80053 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -507,6 +507,11 @@ struct InlineCompletionState { enum InlineCompletionHighlight {} +pub enum MenuInlineCompletionsPolicy { + Never, + ByProvider, +} + #[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Debug, Default)] struct EditorActionId(usize); @@ -678,6 +683,7 @@ pub struct Editor { // inline completions based on its mode. enable_inline_completions: bool, show_inline_completions_override: Option, + menu_inline_completions_policy: MenuInlineCompletionsPolicy, inlay_hint_cache: InlayHintCache, diff_map: DiffMap, next_inlay_id: usize, @@ -1336,6 +1342,7 @@ impl Editor { editor_actions: Rc::default(), show_inline_completions_override: None, enable_inline_completions: true, + menu_inline_completions_policy: MenuInlineCompletionsPolicy::ByProvider, custom_context_menu: None, show_git_blame_gutter: false, show_git_blame_inline: false, @@ -1757,6 +1764,10 @@ impl Editor { } } + pub fn set_menu_inline_completions_policy(&mut self, value: MenuInlineCompletionsPolicy) { + self.menu_inline_completions_policy = value; + } + pub fn set_autoindent(&mut self, autoindent: bool) { if autoindent { self.autoindent_mode = Some(AutoindentMode::EachLine); @@ -5037,7 +5048,13 @@ impl Editor { } fn show_inline_completions_in_menu(&self, cx: &AppContext) -> bool { - EditorSettings::get_global(cx).show_inline_completions_in_menu + let by_provider = matches!( + self.menu_inline_completions_policy, + MenuInlineCompletionsPolicy::ByProvider + ); + + by_provider + && EditorSettings::get_global(cx).show_inline_completions_in_menu && self .inline_completion_provider() .map_or(false, |provider| provider.show_completions_in_menu())