Repository navigation
fix(muya): keep a nested sublist when forward-deleting an empty list item (#1845) - #4725
Merged
Merged
Conversation
…ge (#1845) Forward-Delete at the end of an empty list item merged only the next item's paragraph text and removed that paragraph. When the next item also held a nested sublist as a sibling of its paragraph, the sublist was stranded as the item's sole child and serialized with a doubled bullet (`* - D`). Relocate the merged paragraph's trailing siblings into the target item before removing the now-empty source item, so the whole content travels up with the text. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This was referenced Sep 15, 2026
Merged
Jocs
added a commit
that referenced
this pull request
Sep 16, 2026
… of the row (#5386) (#5422) * fix(muya): keep blocks after a paragraph merged into a table cell out of the row (#5386) Forward Delete at the end of a table's last cell merges the next paragraph into the cell. Since #4725 (#1845), when that paragraph sits in another container, `Format.deleteHandler` moves the blocks that follow it next to `this.parent`. For a cell that parent is `table.cell`, so the blocks were inserted into `table.row`. It also took the branch when the paragraph was a plain sibling of the table, because a cell's parent never shares the paragraph's container. The json flush then threw "Cannot use numerical key for object container", the failed operation stayed queued, and every later edit threw too and never reached the saved markdown. Use `getAnchor()` instead: the parent block for paragraphs and headings, as before, and the whole table for a cell. A paragraph after the table is merged without moving anything, and a merged list item's sublist lands after the table. Fixes #5386 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * test(muya): e2e for forward Delete at the end of a table's last cell (#5386) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Jocs
added a commit
that referenced
this pull request
Sep 16, 2026
…ge (#5423) Delete at the end of a paragraph merges the next paragraph into it. #4725 (fixing #1845) made that merge move every block after the next paragraph out of its container whenever the two paragraphs sat in different containers, so a nested sublist travels up with its list item's text. The check did not require the container to be a list item, so merging a blockquote's first paragraph also moved the quote's remaining paragraphs out of it and the quote disappeared. Only move the trailing blocks when the next paragraph's container is a list item or a task list item. List items and task list items still carry their trailing blocks along; a blockquote keeps its later paragraphs. Fixes #5423 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Jocs
added a commit
that referenced
this pull request
Sep 16, 2026
…ge (#5423) (#5424) * fix(muya): keep the rest of a blockquote quoted on forward-Delete merge (#5423) Delete at the end of a paragraph merges the next paragraph into it. #4725 (fixing #1845) made that merge move every block after the next paragraph out of its container whenever the two paragraphs sat in different containers, so a nested sublist travels up with its list item's text. The check did not require the container to be a list item, so merging a blockquote's first paragraph also moved the quote's remaining paragraphs out of it and the quote disappeared. Only move the trailing blocks when the next paragraph's container is a list item or a task list item. List items and task list items still carry their trailing blocks along; a blockquote keeps its later paragraphs. Fixes #5423 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * test(muya): e2e for forward Delete before a blockquote (#5423) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * docs(muya): trim the forward-Delete merge comments (#5423) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1845
Problem
Pressing Delete (forward-delete) at the end of an empty list item, where the next item owns a nested sublist, produced a doubled bullet:
instead of the expected
Root cause
Format.deleteHandlermerges the next paragraph's text into the current content and then removes the next paragraph. The removal walks up only through only-child ancestors. When the next item's paragraph has a following sibling (a nested sublist), the walk stops at the paragraph, so just the paragraph is removed — leaving the sublist as the item's sole child. On serialization a list item that begins directly with a sublist renders with a second bullet (* - D).Reproduced against the real engine (boot Muya, empty the first item, route a
DeletethroughdeleteHandler, read backgetMarkdown()/getState()).Fix
When the merge crosses a list-item boundary, relocate the merged paragraph's trailing siblings (the sublist) into the target item right after the merged paragraph, before removing the source paragraph. The source item is then empty and is removed whole by the existing only-child walk-up. Flat same-container merges (plain paragraph + paragraph) are untouched.
Tests
Added two regression tests to
deleteMerge.spec.tsdriving the real handler: the output no longer contains a doubled bullet, and the merged text + sublist land in the surviving item. Full muya unit suite (1302), CommonMark/GFM conformance (1347), lint, typecheck, and circular-dep checks all pass.