aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-02-17 11:58:35 +0000
committerGitHub <[email protected]>2021-02-17 11:58:35 +0000
commit5cd7a0f2c5a7948dcd6b1838e1497c560d5c65a1 (patch)
treed019f37897f2902244ff726dacbf19346e23d4d5
parent2920e7b28b58400a9026e92f28fc0304d71c7376 (diff)
parent528a0bcf9b0e4ad1e89d21c9c8df3c55aa3ade00 (diff)
Merge #7704
7704: Avoid transmitting unchanged diagnostics r=matklad a=michalmuskala Reading through the code for diagnostics and observing debug logs, I noticed that diagnostics are transmitted after every change for every opened file, even if they haven't changed (especially visible for files with no diagnostics). This change avoids marking files as "changed" if diagnostics are the same to what was already sent before. This will only work if diagnostics are always produced in the same order, but from my limited testing it seems this is the case. Co-authored-by: Michał Muskała <[email protected]>
-rw-r--r--crates/rust-analyzer/src/diagnostics.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/diagnostics.rs b/crates/rust-analyzer/src/diagnostics.rs
index ee6f2a867..f01548c50 100644
--- a/crates/rust-analyzer/src/diagnostics.rs
+++ b/crates/rust-analyzer/src/diagnostics.rs
@@ -65,6 +65,17 @@ impl DiagnosticCollection {
65 file_id: FileId, 65 file_id: FileId,
66 diagnostics: Vec<lsp_types::Diagnostic>, 66 diagnostics: Vec<lsp_types::Diagnostic>,
67 ) { 67 ) {
68 if let Some(existing_diagnostics) = self.native.get(&file_id) {
69 if existing_diagnostics.len() == diagnostics.len()
70 && diagnostics
71 .iter()
72 .zip(existing_diagnostics)
73 .all(|(new, existing)| are_diagnostics_equal(new, existing))
74 {
75 return;
76 }
77 }
78
68 self.native.insert(file_id, diagnostics); 79 self.native.insert(file_id, diagnostics);
69 self.changes.insert(file_id); 80 self.changes.insert(file_id);
70 } 81 }