Skip to content

[Bug] Forward Delete in a table's last cell throws "Cannot use numerical key for object container" when two blocks follow the table, and later edits are lost #5386

Closed

Description

@Jocs

Description

Pressing forward Delete at the end of the bottom-right table cell, when at least two blocks follow the table, opens the "Unexpected renderer process error" dialog. Every later keystroke, in any cell, opens it again. The edits appear on screen, but the document is never marked modified: File > Save writes the original file, and everything typed after the Delete is lost. With only one block after the table the same Delete works.

Steps to Reproduce

  1. Create table.md with exactly this content:
    | x | y |
    | - | - |
    | 1 | 2 |
    
    p
    
    q
  2. Open it in MarkText.
  3. Click just to the right of the 2 in the bottom-right cell, so the caret is at the end of the cell.
  4. Press forward Delete (⌦ on a full keyboard, fn+delete on a Mac laptop). Backspace does not trigger it.
  5. Type z.
  6. Click after x in the header cell and type w.
  7. Choose File > Save, close the file and open it again. Check the header cell: it shows x, not xw.

Table inside a list item (steps 3–5 the same):

- a

  | x | y |
  | - | - |
  | 1 | 2 |
- b
  - c

For comparison, remove the last two lines (the blank line and q) from table.md: the same steps then work without errors, and the file saves | xw | y | / | 1 | 2zp |.

Expected Behavior

No error, as with a single paragraph after the table: p is merged into the cell (2p, then 2zp) and q stays a separate paragraph below the table. The document is marked modified, and the saved file matches the screen (| xw | y |, | 1 | 2zp |, then q). In the list variant, c stays a list item outside the table.

Actual Behavior

  • The Delete opens the "Unexpected renderer process error" dialog with Cannot use numerical key for object container. Typing z, and typing w in the header cell, each open it again. Clicks do not.
  • The cell shows 2p, then 2zp. q is drawn immediately right of the last row, on the table's right border.
  • The unsaved marker never appears in the title bar.
  • File > Save leaves the file byte-for-byte unchanged. After reopening, the original table, p and q are shown, and the header cell reads x.
  • List variant: the cell shows 2b, then 2zb, and c with its bullet is drawn to the right of the row. Same dialog on every keystroke, no unsaved marker, file unchanged after Save.

Screenshots / Logs

Error: Cannot use numerical key for object container
    at assert (index-_m8tBt4l.js:146967:24)
    at insertChildMut (index-_m8tBt4l.js:147006:99)
    at drop2 (index-_m8tBt4l.js:147111:127)
    at drop2 (index-_m8tBt4l.js:147108:27)
    at drop2 (index-_m8tBt4l.js:147108:27)
    ... JSONState._apply ← JSONState._flushOperationCache

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

Possible cause (unverified): Format.deleteHandler in packages/muya/src/block/base/format.ts moves the blocks after the merged paragraph next to this.parent, assuming that parent is a paragraph (#4725). In a table cell the parent is the cell, so q (or the - c sub-list) is inserted into the table row, the JSON state operation fails, and the failed operation stays queued so every later flush throws.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bug🔭 area/muya🚧 needs triage🦖 table block

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions