diff options
author | Michael Davis | 2022-09-20 07:08:58 +0000 |
---|---|---|
committer | GitHub | 2022-09-20 07:08:58 +0000 |
commit | 8988c1ecc757bb4d1c2372d8b8a78bae6a1fd85e (patch) | |
tree | 8f720d52da74ef7ca0485d4f7d5adcc62ebe11a8 | |
parent | 947ff63e6d31d7926aff83ebb328e03a10deceb9 (diff) |
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.
-rw-r--r-- | helix-view/src/document.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 8ebc9002..2ef99c6a 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -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() { |