diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 4f43db0a5c..a9618ce1e8 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -209,6 +209,7 @@ impl ProjectDiagnosticsEditor { .detach(); cx.observe_global_in::(window, |this, window, cx| { this.include_warnings = cx.global::().0; + this.diagnostics.clear(); this.update_all_excerpts(window, cx); }) .detach(); @@ -300,11 +301,8 @@ impl ProjectDiagnosticsEditor { } } - fn toggle_warnings(&mut self, _: &ToggleWarnings, window: &mut Window, cx: &mut Context) { - self.include_warnings = !self.include_warnings; - cx.set_global(IncludeWarnings(self.include_warnings)); - self.update_all_excerpts(window, cx); - cx.notify(); + fn toggle_warnings(&mut self, _: &ToggleWarnings, _: &mut Window, cx: &mut Context) { + cx.set_global(IncludeWarnings(!self.include_warnings)); } fn focus_in(&mut self, window: &mut Window, cx: &mut Context) { @@ -482,7 +480,10 @@ impl ProjectDiagnosticsEditor { editor.change_selections(Some(Autoscroll::fit()), window, cx, |s| { s.select_anchor_ranges([range_to_select]); }) - }) + }); + if this.focus_handle.is_focused(window) { + this.editor.read(cx).focus_handle(cx).focus(window); + } } }