Don't focus results editor on `cmd-shift-f` when there are no results

Antonio Scandurra created

Change summary

crates/find/src/project_find.rs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

Detailed changes

crates/find/src/project_find.rs 🔗

@@ -22,7 +22,6 @@ 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(true), Some("Workspace")),
@@ -385,7 +384,9 @@ impl ProjectFindView {
 
     fn toggle_focus(&mut self, _: &ToggleFocus, cx: &mut ViewContext<Self>) {
         if self.query_editor.is_focused(cx) {
-            cx.focus(&self.results_editor);
+            if !self.model.read(cx).highlighted_ranges.is_empty() {
+                cx.focus(&self.results_editor);
+            }
         } else {
             cx.focus(&self.query_editor);
         }