From e80708eba7e9959fa720e2563231bba542570295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sat, 6 Nov 2021 18:58:40 +0900 Subject: [PATCH] Make sure document diagnostics are sorted --- helix-core/src/diagnostic.rs | 2 +- helix-view/src/document.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/helix-core/src/diagnostic.rs b/helix-core/src/diagnostic.rs index ab47e075..ad1ba16a 100644 --- a/helix-core/src/diagnostic.rs +++ b/helix-core/src/diagnostic.rs @@ -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, diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 0d86143b..ce5df8ee 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -918,6 +918,9 @@ impl Document { pub fn set_diagnostics(&mut self, diagnostics: Vec) { self.diagnostics = diagnostics; + // sort by range + self.diagnostics + .sort_unstable_by_key(|diagnostic| diagnostic.range); } }