Use DoubleEndedIterator instead of collect to Vec for reversing

Co-authored-by: Pascal Kuthe <pascal.kuthe@semimod.de>
pull/16/head
Philipp Mildenberger 1 year ago
parent dd2f74794a
commit 0637691eb1

@ -3076,8 +3076,6 @@ fn goto_prev_diag(cx: &mut Context) {
let diag = doc let diag = doc
.shown_diagnostics() .shown_diagnostics()
.collect::<Vec<_>>()
.into_iter()
.rev() .rev()
.find(|diag| diag.range.start < cursor_pos) .find(|diag| diag.range.start < cursor_pos)
.or_else(|| doc.shown_diagnostics().last()); .or_else(|| doc.shown_diagnostics().last());

@ -1607,7 +1607,7 @@ impl Document {
&self.diagnostics &self.diagnostics
} }
pub fn shown_diagnostics(&self) -> impl Iterator<Item = &Diagnostic> { pub fn shown_diagnostics(&self) -> impl Iterator<Item = &Diagnostic> + DoubleEndedIterator {
let ls_ids: HashSet<_> = self let ls_ids: HashSet<_> = self
.language_servers_with_feature(LanguageServerFeature::Diagnostics) .language_servers_with_feature(LanguageServerFeature::Diagnostics)
.iter() .iter()

Loading…
Cancel
Save