From f6b7cbd5cf41c5d8d059244832c1d4d06c025e51 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 25 Feb 2022 19:48:43 -0700 Subject: [PATCH] Always open a new project find on `alt-cmd-shift-F` --- crates/find/src/project_find.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/crates/find/src/project_find.rs b/crates/find/src/project_find.rs index fd590e93b11582b6feade4510fac280a7cf490b7..c97e37168c17e1c43a8dc95062d33d1c828d0765 100644 --- a/crates/find/src/project_find.rs +++ b/crates/find/src/project_find.rs @@ -15,16 +15,18 @@ use std::{ use util::ResultExt as _; use workspace::{Item, ItemHandle, ItemNavHistory, ItemView, Settings, Workspace}; -action!(Deploy); +action!(Deploy, bool); action!(Search); action!(ToggleSearchOption, SearchOption); action!(ToggleFocus); pub fn init(cx: &mut MutableAppContext) { cx.add_bindings([ + Binding::new("cmd-shift-F", ToggleFocus, Some("ProjectFindView")), Binding::new("cmd-shift-F", ToggleFocus, Some("ProjectFindView")), Binding::new("cmd-f", ToggleFocus, Some("ProjectFindView")), - Binding::new("cmd-shift-F", Deploy, Some("Workspace")), + Binding::new("cmd-shift-F", Deploy(true), Some("Workspace")), + Binding::new("cmd-alt-shift-F", Deploy(false), Some("Workspace")), Binding::new("enter", Search, Some("ProjectFindView")), ]); cx.add_action(ProjectFindView::deploy); @@ -333,13 +335,19 @@ impl ItemView for ProjectFindView { } impl ProjectFindView { - fn deploy(workspace: &mut Workspace, _: &Deploy, cx: &mut ViewContext) { - if let Some(existing) = workspace.item_of_type::(cx) { - workspace.activate_item(&existing, cx); - } else { - let model = cx.add_model(|cx| ProjectFind::new(workspace.project().clone(), cx)); - workspace.open_item(model, cx); + fn deploy( + workspace: &mut Workspace, + &Deploy(activate_existing): &Deploy, + cx: &mut ViewContext, + ) { + if activate_existing { + if let Some(existing) = workspace.item_of_type::(cx) { + workspace.activate_item(&existing, cx); + return; + } } + let model = cx.add_model(|cx| ProjectFind::new(workspace.project().clone(), cx)); + workspace.open_item(model, cx); } fn search(&mut self, _: &Search, cx: &mut ViewContext) {