Skip to content

Commit 51fa22f

Browse files
everett1992autozimu
authored andcommitted
Sort diagnostics by line number to prevent stale signs
Some signs would not be removed from the sign column when their diagnostic was fixed. Debugging revealed that signs_to_add would include two signs for the same line. `state.signs`is keyed by line number so the second sign for a line will overwrite the first when signs_to_add is recorded in state. The first sign's id is lost when it's overwritten so it can't be removed. signs_to_add included two signs for the same line because itertools `group_by` only groups consecutive runs (it's more efficient, you only need to remember the current group and can flush it when the key changes). This quick fix sorts diagnostics by line number so that group_by gives us one group per line number. fixes #952
1 parent df4a931 commit 51fa22f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/language_server_protocol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,6 +2536,7 @@ impl LanguageClient {
25362536
diag.severity.unwrap_or(DiagnosticSeverity::Hint),
25372537
)
25382538
})
2539+
.sorted_by_key(|(line, _)| *line)
25392540
.group_by(|(line, _)| *line)
25402541
.into_iter()
25412542
.filter_map(|(_, group)| group.min_by_key(|(_, severity)| *severity))

0 commit comments

Comments
 (0)