on master help sign in
consistent diagnostic sorting
commit783ff27b1ba901e30dbf9897f4faaeb123bebb12 authorPascal Kuthe <pascal.kuthe@semimod.de> dateSat 20 May 2023, 21:29 (3 years ago) parent515ef17
2 files changed+17−5
helix-term/src/application.rs+3−1 helix-view/src/document.rs+14−4
helix-term/src/application.rs+3−1
@@ -907,7 +907,9 @@ impl Application {
907907
908908 // Sort diagnostics first by severity and then by line numbers.
909909 // Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order
910− diagnostics.sort_unstable_by_key(|(d, _)| (d.severity, d.range.start));
910+ diagnostics.sort_unstable_by_key(|(d, server_id)| {
911+ (d.severity, d.range.start, *server_id)
912+ });
911913 }
912914 Notification::ShowMessage(params) => {
913915 log::warn!("unhandled window/showMessage: {:?}", params);
helix-view/src/document.rs+14−4
@@ -1240,8 +1240,13 @@ impl Document {
12401240 true
12411241 });
12421242
1243− self.diagnostics
1244− .sort_unstable_by_key(|diagnostic| diagnostic.range);
1243+ self.diagnostics.sort_unstable_by_key(|diagnostic| {
1244+ (
1245+ diagnostic.range,
1246+ diagnostic.severity,
1247+ diagnostic.language_server_id,
1248+ )
1249+ });
12451250
12461251 // Update the inlay hint annotations' positions, helping ensure they are displayed in the proper place
12471252 let apply_inlay_hint_changes = |annotations: &mut Rc<[InlineAnnotation]>| {
@@ -1738,8 +1743,13 @@ impl Document {
17381743 });
17391744 }
17401745 self.diagnostics.extend(diagnostics);
1741− self.diagnostics
1742− .sort_unstable_by_key(|diagnostic| diagnostic.range);
1746+ self.diagnostics.sort_unstable_by_key(|diagnostic| {
1747+ (
1748+ diagnostic.range,
1749+ diagnostic.severity,
1750+ diagnostic.language_server_id,
1751+ )
1752+ });
17431753 }
17441754
17451755 pub fn clear_diagnostics(&mut self, language_server_id: usize) {