Unnamed repository; edit this file 'description' to name the repository.
fix: Fix flycheck cancellations leaving stale errors
Lukas Wirth 2025-01-02
parent 7e639ee · commit 189baf6
-rw-r--r--crates/rust-analyzer/src/flycheck.rs32
1 files changed, 18 insertions, 14 deletions
diff --git a/crates/rust-analyzer/src/flycheck.rs b/crates/rust-analyzer/src/flycheck.rs
index 16ed674406..675588a00b 100644
--- a/crates/rust-analyzer/src/flycheck.rs
+++ b/crates/rust-analyzer/src/flycheck.rs
@@ -353,19 +353,7 @@ impl FlycheckActor {
package_id: None,
});
} else {
- for (package_id, status) in mem::take(&mut self.package_status) {
- if let DiagnosticReceived::No = status {
- tracing::trace!(
- flycheck_id = self.id,
- package_id = package_id.repr,
- "clearing diagnostics"
- );
- self.send(FlycheckMessage::ClearDiagnostics {
- id: self.id,
- package_id: Some(package_id),
- });
- }
- }
+ self.send_clear_diagnostics();
}
self.report_progress(Progress::DidFinish(res));
@@ -429,7 +417,23 @@ impl FlycheckActor {
command_handle.cancel();
self.command_receiver.take();
self.report_progress(Progress::DidCancel);
- self.package_status.clear();
+ self.send_clear_diagnostics();
+ }
+ }
+
+ fn send_clear_diagnostics(&mut self) {
+ for (package_id, status) in mem::take(&mut self.package_status) {
+ if let DiagnosticReceived::No = status {
+ tracing::trace!(
+ flycheck_id = self.id,
+ package_id = package_id.repr,
+ "clearing diagnostics"
+ );
+ self.send(FlycheckMessage::ClearDiagnostics {
+ id: self.id,
+ package_id: Some(package_id),
+ });
+ }
}
}