on master help sign in
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.

commit8988c1ecc757bb4d1c2372d8b8a78bae6a1fd85e authorMichael Davis <mcarsondavis@gmail.com> dateTue 20 Sep 2022, 02:08 (4 years ago) parent947ff63
1 file changed+2
helix-view/src/document.rs+2
helix-view/src/document.rs+2
@@ -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() {