on master help sign in
Sub sort diagnostics by line number
0c10468Gokul Soumya
helix-term/src/application.rs+4−8
@@ -572,15 +572,11 @@ impl Application {
572 doc.set_diagnostics(diagnostics);
572 doc.set_diagnostics(diagnostics);
573 }
573 }
574
574
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
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()
580− } else {
581− std::cmp::Ordering::Equal
582− }
583− });
584
580
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.