Skip to content

Commit bfa0c0c

Browse files
committed
Do not alter diagnostics order sent by server when used in quickfix
Fix #916
1 parent a7d3456 commit bfa0c0c

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/language_server_protocol.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,19 +1923,6 @@ impl LanguageClient {
19231923
})
19241924
.map(Clone::clone)
19251925
.collect::<Vec<_>>();
1926-
diagnostics.sort_by_key(
1927-
// First sort by line.
1928-
// Then severity descendingly. Error should come last since when processing item comes
1929-
// later will override its precedance.
1930-
// Then by character descendingly.
1931-
|diagnostic| {
1932-
(
1933-
diagnostic.range.start.line,
1934-
-(diagnostic.severity.unwrap_or(DiagnosticSeverity::Hint) as i8),
1935-
-(diagnostic.range.start.line as i64),
1936-
)
1937-
},
1938-
);
19391926

19401927
self.update(|state| {
19411928
state
@@ -1949,6 +1936,20 @@ impl LanguageClient {
19491936
if filename != current_filename.canonicalize() {
19501937
return Ok(());
19511938
}
1939+
1940+
// Sort diagnostics as pre-process for display.
1941+
// First sort by line.
1942+
// Then severity descending. Error should come last since when processing item comes
1943+
// later will override its precedence.
1944+
// Then by character descending.
1945+
diagnostics.sort_by_key(|diagnostic| {
1946+
(
1947+
diagnostic.range.start.line,
1948+
-(diagnostic.severity.unwrap_or(DiagnosticSeverity::Hint) as i8),
1949+
-(diagnostic.range.start.line as i64),
1950+
)
1951+
});
1952+
19521953
self.process_diagnostics(&current_filename, &diagnostics)?;
19531954
self.update(|state| {
19541955
state.viewports.remove(&filename);

0 commit comments

Comments
 (0)