summaryrefslogtreecommitdiff
path: root/helix-term/src/application.rs
diff options
context:
space:
mode:
authorGokul Soumya2022-07-05 12:12:14 +0000
committerBlaž Hrastnik2022-07-06 11:06:46 +0000
commit0c104685c024a03cd857c0adcedea55b694eb604 (patch)
treed112f486cc7594e774f3999d2817eaf99a53455a /helix-term/src/application.rs
parent2c37e25cb552f1b64ad6815bb03c40d6d5aacb24 (diff)
Sub sort diagnostics by line number
Diffstat (limited to 'helix-term/src/application.rs')
-rw-r--r--helix-term/src/application.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index df14f5e3..d3899075 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -572,15 +572,11 @@ impl Application {
doc.set_diagnostics(diagnostics);
}
- // Sort diagnostics first by URL and then by severity.
+ // Sort diagnostics first by severity and then by line numbers.
// Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order
- params.diagnostics.sort_unstable_by(|a, b| {
- if let (Some(a), Some(b)) = (a.severity, b.severity) {
- a.partial_cmp(&b).unwrap()
- } else {
- std::cmp::Ordering::Equal
- }
- });
+ params
+ .diagnostics
+ .sort_unstable_by_key(|d| (d.severity, d.range.start));
// Insert the original lsp::Diagnostics here because we may have no open document
// for diagnosic message and so we can't calculate the exact position.