@@ -572,15 +572,11 @@ impl Application {
572 doc.set_diagnostics(diagnostics);
572 doc.set_diagnostics(diagnostics);
575− // Sort diagnostics first by URL and then by severity.
575+ // Sort diagnostics first by severity and then by line numbers.
576 // Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order
576 // Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order
577− params.diagnostics.sort_unstable_by(|a, b| {
578+ .diagnostics
578− if let (Some(a), Some(b)) = (a.severity, b.severity) {
579+ .sort_unstable_by_key(|d| (d.severity, d.range.start));
579− a.partial_cmp(&b).unwrap()
581− std::cmp::Ordering::Equal
585 // Insert the original lsp::Diagnostics here because we may have no open document
581 // Insert the original lsp::Diagnostics here because we may have no open document
586 // for diagnosic message and so we can't calculate the exact position.
582 // for diagnosic message and so we can't calculate the exact position.