aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/document.rs
diff options
context:
space:
mode:
authorPascal Kuthe2023-03-26 16:10:09 +0000
committerBlaž Hrastnik2023-12-27 06:28:14 +0000
commit8653e1b02f6193330f8b0f2afff0a2ff103bd6a4 (patch)
treef6a04a6e55b437359d77a8d857e803593c625ef3 /helix-view/src/document.rs
parentc874a896a5151043a5cd7336e12ebc3a928fc677 (diff)
Add config to mark diagnostic sources as persistent
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs21
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);
}