[pull] develop from marktext:develop#95
Merged
Merged
Conversation
…its (#4669) * fix(muya): invert undo/redo ops against the live document History._change rebuilt the reverse op with the bare `json1.type.invert`, which trusts the removed values carried in the op. A coalesced entry that removes a subtree containing a text edit records the POST-edit removed value (e.g. an empty list item after the typed characters were composed away), so redo re-inserted a node missing the typed text and a follow-up edit threw "The op is too long for this document". Invert against the current json state with `invertWithDoc` so the true removed value is reread, keeping undo/redo lossless. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(muya): append at end when undo/redo replaces the last block The incremental updateContents walker mishandled a block replace at the last child index: the pick phase removes the old block, then drop calls `insertBefore(newBlock, ref)` where `ref` is now undefined — a no-op, so the new block was silently dropped and the live DOM desynced from the json state. A later op then walked a missing path and crashed with "Cannot read properties of undefined (reading 'blockName')". Append the block when there is no insert reference (end of the list). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(muya): restore selection by path after a structural undo/redo Restoring an undo/redo selection trusted the cached `anchor.block` / `focus.block` references, but a structural op (e.g. a paragraph→list replace) detaches those blocks. Setting a DOM range on a detached node logged "addRange(): The given range isn't in document", and reading the detached block's path/blockName in a later getSelection() threw. Re-resolve both endpoints from their path against the fresh tree and focus a valid block when the path no longer points at content; bail out of getSelection() when an endpoint is detached. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(muya): cover undo/redo of a coalesced paragraph→list + text edit Reproduces the reported corruption (type "- " to make a list, type text, undo twice, redo): redo must restore the typed text losslessly and the caret-inside-converted-block path must not crash. Asserts the live block tree (not just getMarkdown, which reads the json state) so a DOM/state desync can't pass silently. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )