From 1e04411066209618ca4bce5081403c2f01901ac3 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 25 Feb 2022 17:23:03 +0100 Subject: [PATCH] Don't focus query editor if there are matches on tab switch --- crates/find/src/project_find.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/find/src/project_find.rs b/crates/find/src/project_find.rs index 24db15c664fcb8c5aba886a6c18769ebd324ca2a..7bd9ee278411d3ef0c1f0db69b16aed6a2e716c5 100644 --- a/crates/find/src/project_find.rs +++ b/crates/find/src/project_find.rs @@ -186,7 +186,11 @@ impl View for ProjectFindView { } fn on_focus(&mut self, cx: &mut ViewContext) { - cx.focus(&self.query_editor); + if self.model.read(cx).highlighted_ranges.is_empty() { + cx.focus(&self.query_editor); + } else { + cx.focus(&self.results_editor); + } } } @@ -227,6 +231,14 @@ impl ItemView for ProjectFindView { true } + fn is_dirty(&self, cx: &AppContext) -> bool { + self.results_editor.read(cx).is_dirty(cx) + } + + fn has_conflict(&self, cx: &AppContext) -> bool { + self.results_editor.read(cx).has_conflict(cx) + } + fn save( &mut self, project: ModelHandle,