diff --git a/crates/assistant_context_editor/src/context_editor.rs b/crates/assistant_context_editor/src/context_editor.rs index be758115c3f244dc13d4180704eedb7e51612c76..7f4b27057fc579121f582e6c82de323375eccce8 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 cf8640e048d667886851c5a040895009946b9c9d..5e09f80053c80d23bb412c28376a3263887f4b7a 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())