Skip to content

Commit 9294965

Browse files
committed
fix: Fix diagnostics not clearing between flychecks
1 parent 9344334 commit 9294965

File tree

1 file changed

+16
-0
lines changed
  • src/tools/rust-analyzer/crates/rust-analyzer/src

1 file changed

+16
-0
lines changed

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

+16
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ struct FlycheckActor {
233233
/// The receiver side of the channel mentioned above.
234234
command_receiver: Option<Receiver<CargoCheckMessage>>,
235235
diagnostics_cleared_for: FxHashSet<Arc<PackageId>>,
236+
diagnostics_cleared_for_all: bool,
236237
diagnostics_received: bool,
237238
}
238239

@@ -264,6 +265,7 @@ impl FlycheckActor {
264265
command_handle: None,
265266
command_receiver: None,
266267
diagnostics_cleared_for: Default::default(),
268+
diagnostics_cleared_for_all: false,
267269
diagnostics_received: false,
268270
}
269271
}
@@ -350,6 +352,7 @@ impl FlycheckActor {
350352
package_id: None,
351353
});
352354
}
355+
self.clear_diagnostics_state();
353356

354357
self.report_progress(Progress::DidFinish(res));
355358
}
@@ -395,6 +398,14 @@ impl FlycheckActor {
395398
package_id: Some(package_id.clone()),
396399
});
397400
}
401+
} else {
402+
if !self.diagnostics_cleared_for_all {
403+
self.diagnostics_cleared_for_all = true;
404+
self.send(FlycheckMessage::ClearDiagnostics {
405+
id: self.id,
406+
package_id: None,
407+
});
408+
}
398409
}
399410
self.send(FlycheckMessage::AddDiagnostic {
400411
id: self.id,
@@ -420,7 +431,12 @@ impl FlycheckActor {
420431
self.command_receiver.take();
421432
self.report_progress(Progress::DidCancel);
422433
}
434+
self.clear_diagnostics_state();
435+
}
436+
437+
fn clear_diagnostics_state(&mut self) {
423438
self.diagnostics_cleared_for.clear();
439+
self.diagnostics_cleared_for_all = false;
424440
self.diagnostics_received = false;
425441
}
426442

0 commit comments

Comments
 (0)