Give correct focus handle when project search has no matches

Julia created

Change summary

crates/gpui2/src/window.rs           | 1 -
crates/search2/src/project_search.rs | 6 +++++-
2 files changed, 5 insertions(+), 2 deletions(-)

Detailed changes

crates/gpui2/src/window.rs 🔗

@@ -489,7 +489,6 @@ impl<'a> WindowContext<'a> {
 
         #[cfg(any(test, feature = "test-support"))]
         {
-            println!("invalidating focus");
             self.window.focus_invalidated = true;
         }
 

crates/search2/src/project_search.rs 🔗

@@ -378,7 +378,11 @@ impl Render for ProjectSearchView {
 
 impl FocusableView for ProjectSearchView {
     fn focus_handle(&self, cx: &AppContext) -> gpui::FocusHandle {
-        self.results_editor.focus_handle(cx)
+        if self.has_matches() {
+            self.results_editor.focus_handle(cx)
+        } else {
+            self.query_editor.focus_handle(cx)
+        }
     }
 }