Skip to content

Commit

Permalink
Re-sort diagnostics after transaction transform (helix-editor#3895)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
the-mikedavis authored and Shekhinah Memmel committed Dec 11, 2022
1 parent d75bf1e commit 64ff181
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ impl Document {
diagnostic.range.end = changes.map_pos(diagnostic.range.end, Assoc::After);
diagnostic.line = self.text.char_to_line(diagnostic.range.start);
}
self.diagnostics
.sort_unstable_by_key(|diagnostic| diagnostic.range);

// emit lsp notification
if let Some(language_server) = self.language_server() {
Expand Down

0 comments on commit 64ff181

Please sign in to comment.