Skip to content

Commit

Permalink
fix: Fix diagnostics not clearing between flychecks
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkirsz committed Jan 7, 2025
1 parent 9344334 commit 9294965
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/tools/rust-analyzer/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,14 @@ 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 +431,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 9294965

Please sign in to comment.