Skip to content

Commit

Permalink
Merge pull request #18864 from alexkirsz/alexkirsz/fix-diagnostics-cl…
Browse files Browse the repository at this point in the history
…earing

fix: Fix diagnostics not clearing between flychecks
  • Loading branch information
Veykril authored Jan 7, 2025
2 parents 2ffdbc3 + fe54502 commit efb8774
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/rust-analyzer/src/flycheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ struct FlycheckActor {
/// The receiver side of the channel mentioned above.
command_receiver: Option<Receiver<CargoCheckMessage>>,
diagnostics_cleared_for: FxHashSet<Arc<PackageId>>,
diagnostics_cleared_for_all: bool,
diagnostics_received: bool,
}

Expand Down Expand Up @@ -264,6 +265,7 @@ impl FlycheckActor {
command_handle: None,
command_receiver: None,
diagnostics_cleared_for: Default::default(),
diagnostics_cleared_for_all: false,
diagnostics_received: false,
}
}
Expand Down Expand Up @@ -350,6 +352,7 @@ impl FlycheckActor {
package_id: None,
});
}
self.clear_diagnostics_state();

self.report_progress(Progress::DidFinish(res));
}
Expand Down Expand Up @@ -395,6 +398,12 @@ impl FlycheckActor {
package_id: Some(package_id.clone()),
});
}
} else if !self.diagnostics_cleared_for_all {
self.diagnostics_cleared_for_all = true;
self.send(FlycheckMessage::ClearDiagnostics {
id: self.id,
package_id: None,
});
}
self.send(FlycheckMessage::AddDiagnostic {
id: self.id,
Expand All @@ -420,7 +429,12 @@ impl FlycheckActor {
self.command_receiver.take();
self.report_progress(Progress::DidCancel);
}
self.clear_diagnostics_state();
}

fn clear_diagnostics_state(&mut self) {
self.diagnostics_cleared_for.clear();
self.diagnostics_cleared_for_all = false;
self.diagnostics_received = false;
}

Expand Down

0 comments on commit efb8774

Please sign in to comment.