diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 3b495b414c..2aa062af91 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/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(); }