@@ -804,6 +804,10 @@ impl GlobalState {
804
804
fn handle_flycheck_msg ( & mut self , message : flycheck:: Message ) {
805
805
match message {
806
806
flycheck:: Message :: AddDiagnostic { id, workspace_root, diagnostic } => {
807
+ if !self . diagnostics_received {
808
+ self . diagnostics . clear_check ( id) ;
809
+ self . diagnostics_received = true ;
810
+ }
807
811
let snap = self . snapshot ( ) ;
808
812
let diagnostics = crate :: diagnostics:: to_proto:: map_rust_diagnostic_to_lsp (
809
813
& self . config . diagnostics_map ( ) ,
@@ -832,7 +836,7 @@ impl GlobalState {
832
836
flycheck:: Message :: Progress { id, progress } => {
833
837
let ( state, message) = match progress {
834
838
flycheck:: Progress :: DidStart => {
835
- self . diagnostics . clear_check ( id ) ;
839
+ self . diagnostics_received = false ;
836
840
( Progress :: Begin , None )
837
841
}
838
842
flycheck:: Progress :: DidCheckCrate ( target) => ( Progress :: Report , Some ( target) ) ,
@@ -848,6 +852,9 @@ impl GlobalState {
848
852
flycheck:: Progress :: DidFinish ( result) => {
849
853
self . last_flycheck_error =
850
854
result. err ( ) . map ( |err| format ! ( "cargo check failed to start: {err}" ) ) ;
855
+ if !self . diagnostics_received {
856
+ self . diagnostics . clear_check ( id) ;
857
+ }
851
858
( Progress :: End , None )
852
859
}
853
860
} ;
0 commit comments