on master help sign in
Sub sort diagnostics by line number
commit0c104685c024a03cd857c0adcedea55b694eb604 authorGokul Soumya <gokulps15@gmail.com> dateTue 5 Jul 2022, 17:42 (4 years ago) parent2c37e25
1 file changed+4−8
helix-term/src/application.rs+4−8
helix-term/src/application.rs+4−8
@@ -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.