From 368301fcecbc000e362ad2785ccfb01bf94d4175 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 25 Feb 2022 18:30:28 +0100 Subject: [PATCH] Reuse a previous project find whenever possible Co-Authored-By: Max Brunsfeld --- crates/find/src/project_find.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/find/src/project_find.rs b/crates/find/src/project_find.rs index 55d25b9dbbe14a0e054ac89d146139ec0345dd07..196cde33a14e7a1670d4e8475dbea1805f673e73 100644 --- a/crates/find/src/project_find.rs +++ b/crates/find/src/project_find.rs @@ -330,8 +330,12 @@ impl ItemView for ProjectFindView { impl ProjectFindView { fn deploy(workspace: &mut Workspace, _: &Deploy, cx: &mut ViewContext) { - let model = cx.add_model(|cx| ProjectFind::new(workspace.project().clone(), cx)); - workspace.open_item(model, cx); + 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 search(&mut self, _: &Search, cx: &mut ViewContext) {