From f877d26c3ad804fee4fc29bdf4529a3c20de69ad Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 8 Feb 2023 18:25:02 +0100 Subject: [PATCH] Merge pull request #2145 from zed-industries/fix-focus-in-project-search Focus results editor only when starting a new project search --- crates/search/src/project_search.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index a4a7a520ae..71a40685e9 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -571,9 +571,9 @@ impl ProjectSearchView { self.active_match_index = None; } else { let prev_search_id = mem::replace(&mut self.search_id, self.model.read(cx).search_id); - let reset_selections = self.search_id != prev_search_id; + let is_new_search = self.search_id != prev_search_id; self.results_editor.update(cx, |editor, cx| { - if reset_selections { + if is_new_search { editor.change_selections(Some(Autoscroll::fit()), cx, |s| { s.select_ranges(match_ranges.first().cloned()) }); @@ -584,7 +584,7 @@ impl ProjectSearchView { cx, ); }); - if self.query_editor.is_focused(cx) { + if is_new_search && self.query_editor.is_focused(cx) { self.focus_results_editor(cx); } }