From 571d0386e25b77bd207ef078855f9eca63ab715d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 6 Jan 2022 08:35:31 -0700 Subject: [PATCH] Re-focus diagnostics editor when transitioning from an empty to a populated state Co-Authored-By: Antonio Scandurra --- crates/diagnostics/src/diagnostics.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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(); }