From 327665986185b4dcee5e975d417217b9118875ad Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 12 Dec 2025 12:32:52 +0100 Subject: [PATCH] minor: Emit `WorkspaceDiagnosticRefresh` when flycheck finished --- crates/rust-analyzer/src/main_loop.rs | 16 ++++++++++++---- crates/rust-analyzer/tests/slow-tests/support.rs | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 77dedf12720c..1a1c0182f87a 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -437,11 +437,17 @@ impl GlobalState { } } Event::Flycheck(message) => { - let _p = tracing::info_span!("GlobalState::handle_event/flycheck").entered(); - self.handle_flycheck_msg(message); + let mut cargo_finished = false; + self.handle_flycheck_msg(message, &mut cargo_finished); // Coalesce many flycheck updates into a single loop turn while let Ok(message) = self.flycheck_receiver.try_recv() { - self.handle_flycheck_msg(message); + self.handle_flycheck_msg(message, &mut cargo_finished); + } + if cargo_finished { + self.send_request::( + (), + |_, _| (), + ); } } Event::TestResult(message) => { @@ -1109,7 +1115,7 @@ impl GlobalState { } } - fn handle_flycheck_msg(&mut self, message: FlycheckMessage) { + fn handle_flycheck_msg(&mut self, message: FlycheckMessage, cargo_finished: &mut bool) { match message { FlycheckMessage::AddDiagnostic { id, @@ -1167,6 +1173,7 @@ impl GlobalState { flycheck::Progress::DidCheckCrate(target) => (Progress::Report, Some(target)), flycheck::Progress::DidCancel => { self.last_flycheck_error = None; + *cargo_finished = true; (Progress::End, None) } flycheck::Progress::DidFailToRestart(err) => { @@ -1177,6 +1184,7 @@ impl GlobalState { flycheck::Progress::DidFinish(result) => { self.last_flycheck_error = result.err().map(|err| format!("cargo check failed to start: {err}")); + *cargo_finished = true; (Progress::End, None) } }; diff --git a/crates/rust-analyzer/tests/slow-tests/support.rs b/crates/rust-analyzer/tests/slow-tests/support.rs index b1b428e7068d..195ad226ae0c 100644 --- a/crates/rust-analyzer/tests/slow-tests/support.rs +++ b/crates/rust-analyzer/tests/slow-tests/support.rs @@ -48,6 +48,7 @@ impl Project<'_> { "enable": false, }, }, + "checkOnSave": false, "procMacro": { "enable": false, }