#5415·marktext

[Bug] Cmd+Backspace across two blocks detaches the second block, and Enter on a list then throws "Failed to execute 'insertBefore'"

Author: JocsCreated Sep 16, 2026Updated Sep 16, 2026
Labels🐛 bug🔭 area/muya🚧 needs triage

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

  1. Create a file with:
    - one
    - two
    
    text
    
  2. Open it in MarkText.
  3. Click between tw and o in two.
  4. Hold Shift and click between te and xt in text (or press Shift+↓), so the selection runs from the list item into the paragraph.
  5. Press Cmd+Backspace.
  6. 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 twxt and the text line 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.