Make sure document diagnostics are sorted
commite80708eba7e9959fa720e2563231bba542570295
authorBlaž Hrastnik <blaz@mxxn.io>
dateSat 6 Nov 2021, 18:58 (5 years ago)
parent0f4cd73
helix-core/src/diagnostic.rs+1−1
@@ -10,7 +10,7 @@ pub enum Severity {
1010}
1111
1212/// A range of `char`s within the text.
13−#[derive(Debug)]
13+#[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq)]
1414pub struct Range {
1515 pub start: usize,
1616 pub end: usize,
helix-view/src/document.rs+3
@@ -918,6 +918,9 @@ impl Document {
918918
919919 pub fn set_diagnostics(&mut self, diagnostics: Vec<Diagnostic>) {
920920 self.diagnostics = diagnostics;
921+ // sort by range
922+ self.diagnostics
923+ .sort_unstable_by_key(|diagnostic| diagnostic.range);
921924 }
922925}
923926