Skip to content

Commit 8988c1e

Browse files
Re-sort diagnostics after transaction transform (#3895)
Applying document-change transactions to diagnostic ranges is not stable with respect to the ordering of diagnostics. This can cause diagnostics to become temporarily unordered with some edits to a document, which can eventually break some invariants/assumptions in syntax::merge. With this change, Document::diagnostics are always sorted.
1 parent 947ff63 commit 8988c1e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

helix-view/src/document.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,8 @@ impl Document {
788788
diagnostic.range.end = changes.map_pos(diagnostic.range.end, Assoc::After);
789789
diagnostic.line = self.text.char_to_line(diagnostic.range.start);
790790
}
791+
self.diagnostics
792+
.sort_unstable_by_key(|diagnostic| diagnostic.range);
791793

792794
// emit lsp notification
793795
if let Some(language_server) = self.language_server() {

0 commit comments

Comments
 (0)