diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 0ba74348f82de7d7efc37c2df8c6890a8c8c8cd3..e2b3a90782a1ad36ea525fdc0d242f8a61b097e8 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -35,10 +35,23 @@ pub fn init(cx: &mut MutableAppContext) { cx.add_action(ProjectSearchView::deploy); cx.add_action(ProjectSearchBar::search); cx.add_action(ProjectSearchBar::search_in_new); - cx.add_action(ProjectSearchBar::toggle_search_option); cx.add_action(ProjectSearchBar::select_next_match); cx.add_action(ProjectSearchBar::select_prev_match); cx.add_action(ProjectSearchBar::toggle_focus); + cx.add_action( + |pane: &mut Pane, + ToggleSearchOption { option }: &ToggleSearchOption, + cx: &mut ViewContext| { + if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::() { + if search_bar.update(cx, |search_bar, cx| { + search_bar.toggle_search_option(*option, cx) + }) { + return; + } + } + cx.propagate_action(); + }, + ); cx.capture_action(ProjectSearchBar::tab); } @@ -653,11 +666,7 @@ impl ProjectSearchBar { } } - fn toggle_search_option( - &mut self, - ToggleSearchOption { option }: &ToggleSearchOption, - cx: &mut ViewContext, - ) { + fn toggle_search_option(&mut self, option: SearchOption, cx: &mut ViewContext) -> bool { if let Some(search_view) = self.active_project_search.as_ref() { search_view.update(cx, |search_view, cx| { let value = match option { @@ -669,6 +678,9 @@ impl ProjectSearchBar { search_view.search(cx); }); cx.notify(); + true + } else { + false } }