From 8653e1b02f6193330f8b0f2afff0a2ff103bd6a4 Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Sun, 26 Mar 2023 18:10:09 +0200 Subject: Add config to mark diagnostic sources as persistent --- helix-view/src/document.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'helix-view/src') 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, + diagnostics: impl IntoIterator, + 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); } -- cgit v1.2.3-70-g09d2