{{ message }}
Repository navigation
fix(muya): keep the document intact when a cut ends in a table (#5400, #5405, #5399, #5398) - #5406
Merged
Merged
Conversation
…#5405, #5399, #5398) A cross-block cut whose end lands in a table went through `removeBlocksIntoTable`, which walked the top-level siblings after the start's outermost block until it met the table. A table inside a list item or a quote is never one of those siblings, so the walk removed every block after the start, took the quote holding the table with it, and then threw while emptying the cells of the detached table (#5400). The blocks after the start inside its own list were never removed either (#5399), the text after the selection end was moved out of its cell into the start block and a table the selection covered whole was left as an empty grid (#5405), and every emptied cell kept showing its old text (#5398). Both paths now share one span removal. `removeSpan` takes the node the span ends at and whether that node itself goes, so a cut into a table stops the span at the table and then clears only the cells the selection covers whole; the end cell keeps what the selection leaves behind. When the selection covers every cell, the table goes with the span, as it already does when the selection runs past it. Clearing a cell re-renders it. A cut with both ends in one table still merges the end cell's tail into the start cell. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WEPLCvFTgbYf35z85XUJop
This was referenced Sep 16, 2026
Closed
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.

Closes #5400
Closes #5405
Closes #5399
Closes #5398
Summary
A cross-block cut whose end lands in a table went through
removeBlocksIntoTable()inpackages/muya/src/clipboard/cut.ts, which removed the top-level blocks between the start's outermost block and the table by walkingbefore.outMostBlock.nextuntil it reached the table. Four problems came out of that:Cannot destructure property 'path' of 'this.parent' as it is null.Both paths now share one span removal:
removeSpan(before, end, removeEnd)removes the blocks after the start inside its containers, the blocks between the two branches, and the blocks beforeendinside its containers.removeEndsays whetherenditself (and the containers it empties) goes. The general path passes the end leaf andtrue.resolveCutEnd()reports that case, since only it knows the offsets.TableRectSelection.emptySelectedCells()already does.A cut with both ends inside one table still merges the end cell's tail into the start cell, unchanged.
Steps to reproduce
Checked with real mouse, keyboard and menu input in a desktop build of
develop@ 0e156b0 and of this branch, using Playwright_electron. Each starts by clicking right afteraand pressing Shift+↓ until the selection reaches the cell named below, then Backspace.develop- a+ a table in its list item, thenafter,more,# heading- a1+ an empty table;after,moreand# headingdeleted- a+ the table with an empty header and1in its cell; the three blocks kept- a, a table in a quote, thenafter- a1; the quote andafterdeleted;Cannot destructure property 'path' of 'this.parent'- a, the quote with its table,after; no error- a/- b, then a table withheadand12345(selection ends inside12345)- a45/- b+ an empty table- a+ the table with an empty header and45in its cell45moved into the list item45stays in its cell- a+ a table, dragging to the end of the last cell- a+ an empty table +tail- a+tailhead/12345Type of change
Test plan
clipboard/__tests__/cutIntoTable5400.spec.ts(8 cases), each checking the json state against the block tree. 7 of them fail ondevelop:editing/cut-into-table-5400.spec.ts(3 tests) with the real keyboard, checking the markdown and the cells' rendered text. All fail ondevelop, pass with the fix (3/3 repeated).clipboard,selection,table-cell-selection,table-rect-clipboardandundo-redo.vitest run1690 tests;lint:types, eslint on the changed files andcheck-circularpass.Notes for reviewers
trackCCut.spec.tscovers it). [Bug] Deleting a selection that ends in a table moves unselected cell text out of the table and keeps a fully selected table #5405 is about text leaving the table, and a text selection across cells is not reachable with real input — dragging across cells starts the table's own rectangular selection.removeBlocksIntoTable()is gone, replaced byremoveSpan()plus the cell clearing inremoveBlocks().By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WEPLCvFTgbYf35z85XUJop