diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index b823d0fd2e..be2ac6a51a 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -45,8 +45,9 @@ pub fn init(cx: &mut MutableAppContext) { cx.add_action(ProjectSearchView::search); cx.add_action(ProjectSearchView::search_in_new); cx.add_action(ProjectSearchView::toggle_search_option); - cx.add_action(ProjectSearchView::toggle_focus); cx.add_action(ProjectSearchView::select_match); + cx.add_action(ProjectSearchView::toggle_focus); + cx.capture_action(ProjectSearchView::tab); } struct ProjectSearch { @@ -521,6 +522,16 @@ impl ProjectSearchView { } } + fn tab(&mut self, _: &editor::Tab, cx: &mut ViewContext) { + if self.query_editor.is_focused(cx) { + if !self.model.read(cx).match_ranges.is_empty() { + self.focus_results_editor(cx); + } + } else { + cx.propagate_action() + } + } + fn focus_results_editor(&self, cx: &mut ViewContext) { self.query_editor.update(cx, |query_editor, cx| { let cursor = query_editor.newest_anchor_selection().head();