Diagnostics small fixes (#28817)

- **Clear diagnostics cache when toggling warnings**
- **Fix focus when first adding excerpts**

Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Conrad Irwin 2025-04-15 16:42:04 -06:00 committed by GitHub
parent f1f5d602fc
commit 5d3718df2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -209,6 +209,7 @@ impl ProjectDiagnosticsEditor {
.detach();
cx.observe_global_in::<IncludeWarnings>(window, |this, window, cx| {
this.include_warnings = cx.global::<IncludeWarnings>().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>) {
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<Self>) {
cx.set_global(IncludeWarnings(!self.include_warnings));
}
fn focus_in(&mut self, window: &mut Window, cx: &mut Context<Self>) {
@ -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);
}
}
}