From 2b5095ac91ea2b9202e16625603d8c29047fcc56 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Wed, 26 Mar 2025 22:18:25 +0100 Subject: [PATCH] assistant2: Fix filtering issue when using @mention completion provider (#27541) Previously `src` would not show up because it was filtered out: image Release Notes: - N/A --- .../src/context_picker/completion_provider.rs | 4 ++++ crates/editor/src/editor.rs | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/assistant2/src/context_picker/completion_provider.rs b/crates/assistant2/src/context_picker/completion_provider.rs index 8570c474496d510521675247a8ead31ab7371708..20d16970a74ad651fdbef40e19ceaa2bb170e6c1 100644 --- a/crates/assistant2/src/context_picker/completion_provider.rs +++ b/crates/assistant2/src/context_picker/completion_provider.rs @@ -544,6 +544,10 @@ impl CompletionProvider for ContextPickerCompletionProvider { fn sort_completions(&self) -> bool { false } + + fn filter_completions(&self) -> bool { + false + } } fn confirm_completion_callback( diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 0c26d012f2e702ffd57da40f8112f5498345ed19..fe1d38a5ae9d63d16cba43968a75fd4c8387b6c3 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -4326,6 +4326,10 @@ impl Editor { .as_ref() .map_or(true, |provider| provider.sort_completions()); + let filter_completions = provider + .as_ref() + .map_or(true, |provider| provider.filter_completions()); + let id = post_inc(&mut self.next_completion_id); let task = cx.spawn_in(window, async move |editor, cx| { async move { @@ -4374,8 +4378,15 @@ impl Editor { completions.into(), ); - menu.filter(query.as_deref(), cx.background_executor().clone()) - .await; + menu.filter( + if filter_completions { + query.as_deref() + } else { + None + }, + cx.background_executor().clone(), + ) + .await; menu.visible().then_some(menu) }; @@ -18041,6 +18052,10 @@ pub trait CompletionProvider { fn sort_completions(&self) -> bool { true } + + fn filter_completions(&self) -> bool { + true + } } pub trait CodeActionProvider {