on master help sign in
consistent diagnostic sorting
783ff27Pascal Kuthe
helix-term/src/application.rs+3−1
@@ -907,7 +907,9 @@ impl Application {
907
907
908 // Sort diagnostics first by severity and then by line numbers.
908 // Sort diagnostics first by severity and then by line numbers.
909 // Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order
909 // 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+ });
911 }
913 }
912 Notification::ShowMessage(params) => {
914 Notification::ShowMessage(params) => {
913 log::warn!("unhandled window/showMessage: {:?}", params);
915 log::warn!("unhandled window/showMessage: {:?}", params);
helix-view/src/document.rs+14−4
@@ -1240,8 +1240,13 @@ impl Document {
1240 true
1240 true
1241 });
1241 });
1242
1242
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+ });
1245
1250
1246 // Update the inlay hint annotations' positions, helping ensure they are displayed in the proper place
1251 // Update the inlay hint annotations' positions, helping ensure they are displayed in the proper place
1247 let apply_inlay_hint_changes = |annotations: &mut Rc<[InlineAnnotation]>| {
1252 let apply_inlay_hint_changes = |annotations: &mut Rc<[InlineAnnotation]>| {
@@ -1738,8 +1743,13 @@ impl Document {
1738 });
1743 });
1739 }
1744 }
1740 self.diagnostics.extend(diagnostics);
1745 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+ });
1743 }
1753 }
1744
1754
1745 pub fn clear_diagnostics(&mut self, language_server_id: usize) {
1755 pub fn clear_diagnostics(&mut self, language_server_id: usize) {