Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix non-cargo flychecks immediately clearing received diagnostics #18848

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 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_received: bool,
}

#[allow(clippy::large_enum_variant)]
Expand Down Expand Up @@ -263,6 +264,7 @@ impl FlycheckActor {
command_handle: None,
command_receiver: None,
diagnostics_cleared_for: Default::default(),
diagnostics_received: false,
}
}

Expand Down Expand Up @@ -339,16 +341,14 @@ impl FlycheckActor {
error
);
}
if self.diagnostics_cleared_for.is_empty() {
if !self.diagnostics_received {
tracing::trace!(flycheck_id = self.id, "clearing diagnostics");
// We finished without receiving any diagnostics.
// Clear everything for good measure
self.send(FlycheckMessage::ClearDiagnostics {
id: self.id,
package_id: None,
});
} else {
self.diagnostics_cleared_for.clear();
}

self.report_progress(Progress::DidFinish(res));
Expand Down Expand Up @@ -382,6 +382,7 @@ impl FlycheckActor {
package_id = package_id.as_ref().map(|it| &it.repr),
"diagnostic received"
);
self.diagnostics_received = true;
if let Some(package_id) = &package_id {
if self.diagnostics_cleared_for.insert(package_id.clone()) {
tracing::trace!(
Expand Down Expand Up @@ -419,6 +420,7 @@ impl FlycheckActor {
self.command_receiver.take();
self.report_progress(Progress::DidCancel);
self.diagnostics_cleared_for.clear();
self.diagnostics_received = false;
Copy link
Member Author

@Veykril Veykril Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug for things not clearing is here, this line and the above should not be gated by the surrounding if let, the handle is taken on a completed check so we don't reset in thst case.

}
}

Expand Down
Loading