[Bug] Cmd+Backspace across two blocks detaches the second block, and Enter on a list then throws "Failed to execute 'insertBefore'"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 61.6k
- Forks
- 4.6k
- Avg merge
- 23h 49m
- Merged PRs (30d)
- 89
Description
Description
Deleting a selection that spans two blocks with Cmd+Backspace removes the second block on screen but not from the document. The block stays in the editor's block tree with its element gone, so a later Enter, Enter at the end of a bullet list opens the "Unexpected renderer process error" dialog with NotFoundError: Failed to execute 'insertBefore' on 'Node'. Other edits that never reach the editor's key handling behave the same way. This is one of the triggers behind #5035.
Steps to Reproduce
- Create a file with:
- one - two text - Open it in MarkText.
- Click between
twandointwo. - Hold Shift and click between
teandxtintext(or press Shift+↓), so the selection runs from the list item into the paragraph. - Press Cmd+Backspace.
- Click at the end of the bullet line, press Enter, then press Enter again.
Expected Behavior
The bullet reads twxt and text is removed from the document as well. The second Enter leaves an empty paragraph below the list. No error.
Actual Behavior
- After step 5 the bullet shows
twxtand thetextline disappears from the screen, but the document (and the saved file) is still- one/- twxt/ blank line /text. - The second Enter in step 6 opens the "Unexpected renderer process error" dialog.
The same happens, over the same selection, with:
- Ctrl+K, Ctrl+D, Ctrl+H and Ctrl+Y on macOS (checked in a Chromium test page, not in the packaged app);
- text committed without a key press, such as the emoji picker (Ctrl+Cmd+Space), dictation or handwriting input (reproduced with synthetic text input; the real macOS emoji picker was not checked).
Screenshots / Logs
NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
at ScrollPage.insertBefore
at ScrollPage.insertAfter
at ParagraphContent._enterInListItem
at ParagraphContent.enterHandler
at ParagraphContent.keydownHandler
Operating System
macOS
MarkText Version
0.20.0-rc.3 (also reproduced on the current develop branch)
OS Version
macOS 27.0 (arm64)
Reproducibility
- I can reliably reproduce this issue
Related
- #5035: the same crash; this is one of its triggers.
- #5381 carried a fix for this before it was narrowed to the setext heading trigger.
Possible cause: muya cuts a selection that spans blocks only in its document keydown handler (packages/muya/src/clipboard/index.ts), and shouldCrossBlockCut deliberately skips keys pressed with Cmd or Ctrl. Input that has no keydown at all never reaches that handler either. Chromium then applies the edit itself across the block elements and deletes the ones in between. A prototype that runs the same cut from a beforeinput handler fixed every route above in Chromium.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/muya/src/clipboard/index.ts and trace the selection-cut handling alongside the reported ScrollPage and ParagraphContent stack entries. Reproduce the cross-block edit and then Enter sequence in MarkText, including input without a keydown. Done means the second block is removed from the document and saved file, the list can be exited with Enter, and no renderer error occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, typescript
- Domain
- desktop, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100