Sub sort diagnostics by line number

pull/2988/head
Gokul Soumya 2 years ago committed by Blaž Hrastnik
parent 2c37e25cb5
commit 0c104685c0

@ -572,15 +572,11 @@ impl Application {
doc.set_diagnostics(diagnostics); 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 // Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order
params.diagnostics.sort_unstable_by(|a, b| { params
if let (Some(a), Some(b)) = (a.severity, b.severity) { .diagnostics
a.partial_cmp(&b).unwrap() .sort_unstable_by_key(|d| (d.severity, d.range.start));
} else {
std::cmp::Ordering::Equal
}
});
// Insert the original lsp::Diagnostics here because we may have no open document // 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. // for diagnosic message and so we can't calculate the exact position.

Loading…
Cancel
Save