diff --git a/crates/find/src/project_find.rs b/crates/find/src/project_find.rs index 0743e2cce0af45d4e8327daab3ddeb3f722f7ae1..ff34015d95b8142339e7aed67769f5483689ad74 100644 --- a/crates/find/src/project_find.rs +++ b/crates/find/src/project_find.rs @@ -13,15 +13,18 @@ use crate::SearchOption; action!(Deploy); action!(Search); action!(ToggleSearchOption, SearchOption); +action!(ToggleFocus); pub fn init(cx: &mut MutableAppContext) { cx.add_bindings([ - Binding::new("cmd-shift-F", Deploy, None), + Binding::new("cmd-shift-F", ToggleFocus, Some("ProjectFindView")), + Binding::new("cmd-shift-F", Deploy, Some("Workspace")), Binding::new("enter", Search, Some("ProjectFindView")), ]); cx.add_action(ProjectFindView::deploy); cx.add_action(ProjectFindView::search); cx.add_action(ProjectFindView::toggle_search_option); + cx.add_action(ProjectFindView::toggle_focus); } struct ProjectFind { @@ -253,6 +256,14 @@ impl ProjectFindView { cx.notify(); } + fn toggle_focus(&mut self, _: &ToggleFocus, cx: &mut ViewContext) { + if self.query_editor.is_focused(cx) { + cx.focus(&self.results_editor); + } else { + cx.focus(&self.query_editor); + } + } + fn on_model_changed(&mut self, _: ModelHandle, cx: &mut ViewContext) { let theme = &self.settings.borrow().theme.find; self.results_editor.update(cx, |editor, cx| {