Make sure document diagnostics are sorted

imgbot
Blaž Hrastnik 3 years ago
parent 0f4cd73000
commit e80708eba7

@ -10,7 +10,7 @@ pub enum Severity {
}
/// A range of `char`s within the text.
#[derive(Debug)]
#[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq)]
pub struct Range {
pub start: usize,
pub end: usize,

@ -918,6 +918,9 @@ impl Document {
pub fn set_diagnostics(&mut self, diagnostics: Vec<Diagnostic>) {
self.diagnostics = diagnostics;
// sort by range
self.diagnostics
.sort_unstable_by_key(|diagnostic| diagnostic.range);
}
}

Loading…
Cancel
Save