From c547a06425fa271d1f556c69274ad521a46f5347 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 12 Nov 2025 09:11:50 +0100 Subject: [PATCH] diagnostics: Close diagnosticsless buffers on refresh (#42503) Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/diagnostics/src/diagnostics.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 2e729cbdf420264d96db6e6fec8317d250ec642c..344ce652969e9a6d54a22769741616def48ab3b1 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -182,7 +182,6 @@ impl ProjectDiagnosticsEditor { project::Event::DiskBasedDiagnosticsFinished { language_server_id } => { log::debug!("disk based diagnostics finished for server {language_server_id}"); this.close_diagnosticless_buffers( - window, cx, this.editor.focus_handle(cx).contains_focused(window, cx) || this.focus_handle.contains_focused(window, cx), @@ -247,10 +246,10 @@ impl ProjectDiagnosticsEditor { window.focus(&this.focus_handle); } } - EditorEvent::Blurred => this.close_diagnosticless_buffers(window, cx, false), - EditorEvent::Saved => this.close_diagnosticless_buffers(window, cx, true), + EditorEvent::Blurred => this.close_diagnosticless_buffers(cx, false), + EditorEvent::Saved => this.close_diagnosticless_buffers(cx, true), EditorEvent::SelectionsChanged { .. } => { - this.close_diagnosticless_buffers(window, cx, true) + this.close_diagnosticless_buffers(cx, true) } _ => {} } @@ -298,12 +297,7 @@ impl ProjectDiagnosticsEditor { /// - have no diagnostics anymore /// - are saved (not dirty) /// - and, if `retain_selections` is true, do not have selections within them - fn close_diagnosticless_buffers( - &mut self, - _window: &mut Window, - cx: &mut Context, - retain_selections: bool, - ) { + fn close_diagnosticless_buffers(&mut self, cx: &mut Context, retain_selections: bool) { let snapshot = self .editor .update(cx, |editor, cx| editor.display_snapshot(cx)); @@ -447,7 +441,7 @@ impl ProjectDiagnosticsEditor { fn focus_out(&mut self, _: FocusOutEvent, window: &mut Window, cx: &mut Context) { if !self.focus_handle.is_focused(window) && !self.editor.focus_handle(cx).is_focused(window) { - self.close_diagnosticless_buffers(window, cx, false); + self.close_diagnosticless_buffers(cx, false); } } @@ -461,8 +455,7 @@ impl ProjectDiagnosticsEditor { }); } }); - self.multibuffer - .update(cx, |multibuffer, cx| multibuffer.clear(cx)); + self.close_diagnosticless_buffers(cx, false); self.project.update(cx, |project, cx| { self.paths_to_update = project .diagnostic_summaries(false, cx)