Don't focus query editor if there are matches on tab switch

Antonio Scandurra created

Change summary

crates/find/src/project_find.rs | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

Detailed changes

crates/find/src/project_find.rs 🔗

@@ -186,7 +186,11 @@ impl View for ProjectFindView {
     }
 
     fn on_focus(&mut self, cx: &mut ViewContext<Self>) {
-        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<Project>,