Skip to content

Commit

Permalink
Merge pull request #18817 from Veykril/push-zzkkotwuyqzt
Browse files Browse the repository at this point in the history
fix: Fix flycheck cancellations leaving stale errors
  • Loading branch information
Veykril authored Jan 2, 2025
2 parents 74d0d4e + efbbf57 commit ec46a15
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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),
});
}
}
}

Expand Down

0 comments on commit ec46a15

Please sign in to comment.