Re-focus diagnostics editor when transitioning from an empty to a populated state

Nathan Sobo and Antonio Scandurra created

Co-Authored-By: Antonio Scandurra <me@as-cii.com>

Change summary

crates/diagnostics/src/diagnostics.rs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

Detailed changes

crates/diagnostics/src/diagnostics.rs 🔗

@@ -389,8 +389,14 @@ impl ProjectDiagnosticsEditor {
             self.path_states.remove(path_ix);
         }
 
-        if self.editor.is_focused(cx) && self.path_states.is_empty() {
-            cx.focus_self();
+        if self.path_states.is_empty() {
+            if self.editor.is_focused(cx) {
+                cx.focus_self();
+            }
+        } else {
+            if cx.handle().is_focused(cx) {
+                cx.focus(&self.editor);
+            }
         }
         cx.notify();
     }