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