Skip to content

Commit

Permalink
Sub sort diagnostics by line number
Browse files Browse the repository at this point in the history
  • Loading branch information
sudormrfbin authored and archseer committed Jul 6, 2022
1 parent 2c37e25 commit 0c10468
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0c10468

Please sign in to comment.