diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 0d02eaca5dca7..c5116efbd89b0 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -898,7 +898,9 @@ impl Application { // Sort diagnostics first by severity and then by line numbers. // Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order - diagnostics.sort_unstable_by_key(|(d, _)| (d.severity, d.range.start)); + diagnostics.sort_unstable_by_key(|(d, server_id)| { + (d.severity, d.range.start, *server_id) + }); } Notification::ShowMessage(params) => { log::warn!("unhandled window/showMessage: {:?}", params); diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 1feab942c7a80..3e67ab0fc2dd7 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -1127,8 +1127,13 @@ impl Document { diagnostic.range.end = changes.map_pos(diagnostic.range.end, assoc); diagnostic.line = self.text.char_to_line(diagnostic.range.start); } - self.diagnostics - .sort_unstable_by_key(|diagnostic| diagnostic.range); + self.diagnostics.sort_unstable_by_key(|diagnostic| { + ( + diagnostic.range, + diagnostic.severity, + diagnostic.language_server_id, + ) + }); // Update the inlay hint annotations' positions, helping ensure they are displayed in the proper place let apply_inlay_hint_changes = |annotations: &mut Rc<[InlineAnnotation]>| { @@ -1624,8 +1629,13 @@ impl Document { }); } self.diagnostics.extend(diagnostics); - self.diagnostics - .sort_unstable_by_key(|diagnostic| diagnostic.range); + self.diagnostics.sort_unstable_by_key(|diagnostic| { + ( + diagnostic.range, + diagnostic.severity, + diagnostic.language_server_id, + ) + }); } pub fn clear_diagnostics(&mut self, language_server_id: usize) {