diff options
| author | David Mládek <david.mladek.cz@gmail.com> | 2024-05-17 01:30:01 +0200 |
|---|---|---|
| committer | David Mládek <david.mladek.cz@gmail.com> | 2024-05-17 01:30:01 +0200 |
| commit | 1287e868e942a352da41a531e4cc9ff5b73ea5fc (patch) | |
| tree | fd38df0c9089ee7d8018089ac97e56aa0733ad19 | |
| parent | 57062170c5c03c827c07c3f9e143c2d6ed7c70e7 (diff) | |
| download | rust-1287e868e942a352da41a531e4cc9ff5b73ea5fc.tar.gz rust-1287e868e942a352da41a531e4cc9ff5b73ea5fc.zip | |
Clear diagnostics only after new ones were received
| -rw-r--r-- | src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs | 2 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs index f64e66183d1..79b87ecd58f 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs @@ -87,6 +87,7 @@ pub(crate) struct GlobalState { pub(crate) flycheck_sender: Sender<flycheck::Message>, pub(crate) flycheck_receiver: Receiver<flycheck::Message>, pub(crate) last_flycheck_error: Option<String>, + pub(crate) diagnostics_received: bool, // Test explorer pub(crate) test_run_session: Option<Vec<flycheck::CargoTestHandle>>, @@ -224,6 +225,7 @@ impl GlobalState { flycheck_sender, flycheck_receiver, last_flycheck_error: None, + diagnostics_received: false, test_run_session: None, test_run_sender, diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs index 5435be3dc27..7acd302867c 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs @@ -804,6 +804,10 @@ impl GlobalState { fn handle_flycheck_msg(&mut self, message: flycheck::Message) { match message { flycheck::Message::AddDiagnostic { id, workspace_root, diagnostic } => { + if !self.diagnostics_received { + self.diagnostics.clear_check(id); + self.diagnostics_received = true; + } let snap = self.snapshot(); let diagnostics = crate::diagnostics::to_proto::map_rust_diagnostic_to_lsp( &self.config.diagnostics_map(), @@ -832,7 +836,7 @@ impl GlobalState { flycheck::Message::Progress { id, progress } => { let (state, message) = match progress { flycheck::Progress::DidStart => { - self.diagnostics.clear_check(id); + self.diagnostics_received = false; (Progress::Begin, None) } flycheck::Progress::DidCheckCrate(target) => (Progress::Report, Some(target)), @@ -848,6 +852,9 @@ impl GlobalState { flycheck::Progress::DidFinish(result) => { self.last_flycheck_error = result.err().map(|err| format!("cargo check failed to start: {err}")); + if !self.diagnostics_received { + self.diagnostics.clear_check(id); + } (Progress::End, None) } }; |
