Skip to content

Commit efbbf57

Browse files
committed
fix: Fix flycheck cancellations leaving stale errors
1 parent 74d0d4e commit efbbf57

File tree

1 file changed

+18
-14
lines changed
  • src/tools/rust-analyzer/crates/rust-analyzer/src

1 file changed

+18
-14
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -353,19 +353,7 @@ impl FlycheckActor {
353353
package_id: None,
354354
});
355355
} else {
356-
for (package_id, status) in mem::take(&mut self.package_status) {
357-
if let DiagnosticReceived::No = status {
358-
tracing::trace!(
359-
flycheck_id = self.id,
360-
package_id = package_id.repr,
361-
"clearing diagnostics"
362-
);
363-
self.send(FlycheckMessage::ClearDiagnostics {
364-
id: self.id,
365-
package_id: Some(package_id),
366-
});
367-
}
368-
}
356+
self.send_clear_diagnostics();
369357
}
370358

371359
self.report_progress(Progress::DidFinish(res));
@@ -429,7 +417,23 @@ impl FlycheckActor {
429417
command_handle.cancel();
430418
self.command_receiver.take();
431419
self.report_progress(Progress::DidCancel);
432-
self.package_status.clear();
420+
self.send_clear_diagnostics();
421+
}
422+
}
423+
424+
fn send_clear_diagnostics(&mut self) {
425+
for (package_id, status) in mem::take(&mut self.package_status) {
426+
if let DiagnosticReceived::No = status {
427+
tracing::trace!(
428+
flycheck_id = self.id,
429+
package_id = package_id.repr,
430+
"clearing diagnostics"
431+
);
432+
self.send(FlycheckMessage::ClearDiagnostics {
433+
id: self.id,
434+
package_id: Some(package_id),
435+
});
436+
}
433437
}
434438
}
435439

0 commit comments

Comments
 (0)