aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorPhilipp Mildenberger2023-03-18 20:10:10 +0000
committerPhilipp Mildenberger2023-05-18 19:48:32 +0000
commit9639f42766a18983dc2298e60bf47a748845bde7 (patch)
treea7e12b9660dce79fe780b1d90c76caaa517bf5e2 /helix-view
parent1122928c2adef0a1c34e90d140c61f84beeb7418 (diff)
Refactor doc.shown_diagnostics to avoid an extra HashSet
Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/document.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 5fec3361..0f800209 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -16,7 +16,7 @@ use serde::de::{self, Deserialize, Deserializer};
use serde::Serialize;
use std::borrow::Cow;
use std::cell::Cell;
-use std::collections::{HashMap, HashSet};
+use std::collections::HashMap;
use std::fmt::Display;
use std::future::Future;
use std::path::{Path, PathBuf};
@@ -1581,13 +1581,16 @@ impl Document {
}
pub fn shown_diagnostics(&self) -> impl Iterator<Item = &Diagnostic> + DoubleEndedIterator {
- let ls_ids: HashSet<_> = self
- .language_servers_with_feature(LanguageServerFeature::Diagnostics)
- .map(|ls| ls.id())
- .collect();
- self.diagnostics
- .iter()
- .filter(move |d| ls_ids.contains(&d.language_server_id))
+ self.diagnostics.iter().filter(|d| {
+ self.language_servers()
+ .find(|ls| ls.id() == d.language_server_id)
+ .and_then(|ls| {
+ let config = self.language_config()?;
+ let features = config.language_servers.get(ls.name())?;
+ Some(features.has_feature(LanguageServerFeature::Diagnostics))
+ })
+ == Some(true)
+ })
}
pub fn replace_diagnostics(