From 11b6ce46e213d4424deff10281ce03123890c3a0 Mon Sep 17 00:00:00 2001 From: Tristan Hume Date: Fri, 9 May 2025 08:29:03 -0400 Subject: [PATCH] Add ability to keybind search filter (#30327) Useful for large monorepos with many subdirectories, users can keybind a filter to their commonly used directories. Release Notes: - Added a new `included_files` field to the `DeploySearch` action to automatically pre-fill which files to include in the search. This lets you use a keybinding to search in a particular folder or for a certain set of files. --------- Co-authored-by: Antonio Scandurra --- crates/search/src/project_search.rs | 6 ++++++ crates/workspace/src/pane.rs | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index b24cb9c97305cb14af23c322e238ee9de0f7f6e4..8485d8e7919e3fdb962bebed2d59b8ee158b3e09 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -988,6 +988,12 @@ impl ProjectSearchView { if let Some(query) = query { search.set_query(&query, window, cx); } + if let Some(included_files) = action.included_files.as_deref() { + search + .included_files_editor + .update(cx, |editor, cx| editor.set_text(included_files, window, cx)); + search.filters_enabled = true; + } search.focus_query_editor(window, cx) }); } diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index c8129701e910877e90abec7128f309251664c932..543ec5186b1b4b63633349e91d61f57b32a532ab 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -154,6 +154,8 @@ pub struct RevealInProjectPanel { pub struct DeploySearch { #[serde(default)] pub replace_enabled: bool, + #[serde(default)] + pub included_files: Option, } impl_actions!( @@ -200,6 +202,7 @@ impl DeploySearch { pub fn find() -> Self { Self { replace_enabled: false, + included_files: None, } } } @@ -3116,6 +3119,7 @@ fn default_render_tab_bar_buttons( "Search Project", DeploySearch { replace_enabled: false, + included_files: None, } .boxed_clone(), )