Skip to content

Commit

Permalink
Merge pull request #18778 from Veykril/push-oontvoqmxkno
Browse files Browse the repository at this point in the history
fix: Fix flycheck diagnostics flickering for binary targets
  • Loading branch information
Veykril authored Dec 28, 2024
2 parents d3bb15e + cf30743 commit dc6cea5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions crates/rust-analyzer/src/flycheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ impl FlycheckActor {
);
}
if self.package_status.is_empty() {
tracing::trace!(flycheck_id = self.id, "clearing diagnostics");
// We finished without receiving any diagnostics.
// That means all of them are stale.
self.send(FlycheckMessage::ClearDiagnostics {
Expand All @@ -354,6 +355,11 @@ impl FlycheckActor {
} 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),
Expand Down Expand Up @@ -385,9 +391,15 @@ impl FlycheckActor {
"diagnostic received"
);
if let Some(package_id) = &package_id {
if !self.package_status.contains_key(package_id) {
self.package_status
.insert(package_id.clone(), DiagnosticReceived::Yes);
if let None | Some(DiagnosticReceived::No) = self
.package_status
.insert(package_id.clone(), DiagnosticReceived::Yes)
{
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.clone()),
Expand Down

0 comments on commit dc6cea5

Please sign in to comment.