[Bug] Typing over a triple-clicked line above a task list or table detaches it, and Enter on a list then throws "Failed to execute 'insertBefore'"
Description
Triple-clicking a line directly above a task list or a table and typing a character removes that line on screen, but not from the document. The line's block stays in the editor's block tree with its element gone, so a later Enter, Enter at the end of a bullet list above it opens the "Unexpected renderer process error" dialog with NotFoundError: Failed to execute 'insertBefore' on 'Node'. This is one of the triggers behind #5035.
Steps to Reproduce
- Create a file with:
- one - two text - [ ] task - Open it in MarkText.
- Triple-click
text. - Type
x. - Click at the end of
two, press Enter, then press Enter again.
With a table in place of the task list (| a | b | / | - | - | / | 1 | 2 |), step 4 detaches the whole table instead.
Expected Behavior
x replaces text in the document and on screen. The second Enter turns the empty bullet into an empty paragraph below the list. No error.
Actual Behavior
- After step 4 the
textline disappears andxshows up inside the task item, while the document (and the saved file) still saystext. - The second Enter in step 5 opens the "Unexpected renderer process error" dialog.
- On the same triple-click selection, before typing: copy puts nothing on the clipboard, and cut, Backspace, Delete, Enter and Cmd+B do nothing. The same happens above a math block or an HTML block.
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 0.20.0-rc.1 and 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.
- #5389: typing over a triple-clicked line swallows the next block. Its task list and table variants are the first half of this bug.
- #5381 carried a fix for this before it was narrowed to the setext heading trigger.
Possible cause: Chromium ends a triple-click selection at offset 0 of the next block. A task list item starts with its checkbox and a table with its figure, so no content leaf holds that end, and TextSelection.getSelection() returns null. Every consumer then sees no selection: the keydown cross-block cut in packages/muya/src/clipboard/index.ts does nothing, copy has nothing to copy, and the typed key's native edit deletes the paragraph's element. Two fixes were prototyped: pulling the selection end back onto text inside a beforeinput handler, and normalizing the selection on selectionchange, which also makes copy, cut and Backspace work on it.
Source: marktext/marktext