Skip to content

[Bug] Cutting from a nested code block's language box replaces the whole list or quote #5368

Closed

Description

@Jocs

Description

When a code block sits inside a list item or a block quote, replacing a selection that starts in its language box (typing, pasting or pressing Backspace over it) replaces the whole list or quote with a single paragraph. Every other list item or quote paragraph is deleted, including content outside the selection.

Shift+↓ from the end of the language box selects exactly such a range (from the language into the first code line).

A code block at the top level of the document is handled correctly (#918): only the code block turns into a paragraph.

Steps to Reproduce

  1. Open a document with:
    - item one
    
      ```js
      const a = 1
      ```
    
    - item two
  2. Click in the code line so the language box js shows, then click right after js.
  3. Press Shift+↓ and type q.

Also with a quote:

> quote
>
> ```js
> code
> ```
>
> tail

(select from the start of js into code, press Backspace).

Expected Behavior

Only the code block that holds the language box collapses into a paragraph, as it does at the top level; the list or quote around it and all its other content stay:

- item one

  jsqnst a = 1

- item two

Actual Behavior

Measured with real mouse and keyboard input in MarkText 0.20.0-rc.2 on macOS, and on develop @ 8bcb1e0 (muya e2e host):

Document Action Saved markdown
list above end of js, Shift+↓, type q jsqnst a = 1 — item one and item two are gone
quote above select js → co, Backspace de — quote and tail are gone
list above plus a paragraph after select from `j stoaf

No error is shown.

Screenshots / Logs

Analysis: collapseLanguageInputCut() (packages/muya/src/clipboard/cut.ts, added for #918) replaces startBlock.outMostBlock with the merged paragraph. For a code block nested in a list or quote the outermost block is the list or quote itself, not the code block.

Operating System

macOS

MarkText Version

0.20.0-rc.2, develop @ 8bcb1e0

OS Version

macOS 27.0

Reproducibility

  • I can reliably reproduce this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bug🔭 area/muya🚧 needs triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions