diff options
author | Pascal Kuthe | 2023-03-26 16:10:09 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2023-12-27 06:28:14 +0000 |
commit | 8653e1b02f6193330f8b0f2afff0a2ff103bd6a4 (patch) | |
tree | f6a04a6e55b437359d77a8d857e803593c625ef3 /helix-view | |
parent | c874a896a5151043a5cd7336e12ebc3a928fc677 (diff) |
Add config to mark diagnostic sources as persistent
Diffstat (limited to 'helix-view')
-rw-r--r-- | helix-view/src/document.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index bb61eaa6..37b8a0bf 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -1706,11 +1706,26 @@ impl Document { pub fn replace_diagnostics( &mut self, - mut diagnostics: Vec<Diagnostic>, + diagnostics: impl IntoIterator<Item = Diagnostic>, + unchanged_sources: &[String], language_server_id: usize, ) { - self.clear_diagnostics(language_server_id); - self.diagnostics.append(&mut diagnostics); + if unchanged_sources.is_empty() { + self.clear_diagnostics(language_server_id); + } else { + self.diagnostics.retain(|d| { + if d.language_server_id != language_server_id { + return true; + } + + if let Some(source) = &d.source { + unchanged_sources.contains(source) + } else { + false + } + }); + } + self.diagnostics.extend(diagnostics); self.diagnostics .sort_unstable_by_key(|diagnostic| diagnostic.range); } |