[Bug] Typing over a triple-clicked line swallows the next block (thematic break, list item, quote, front matter) · Issue #5389 · marktext/marktext · GitHub
Skip to content

[Bug] Typing over a triple-clicked line swallows the next block (thematic break, list item, quote, front matter) #5389

Closed

Description

@Jocs

Description

Triple-clicking a line highlights only that line, but typing a character also consumes the block below it. A thematic break disappears, a list's first item or a quote's text is pulled into the line, and in front matter the body paragraph is pulled into the front matter while the title line is lost. The damage is visible immediately and is written to the saved file. With a table or task list below, the screen changes but the file does not; with a heading below, nothing is selected.

Steps to Reproduce

  1. Create t.md with:
    alpha beta
    
    ***
  2. Open it in MarkText.
  3. Triple-click on the word alpha (three quick clicks without moving the mouse). Only the line alpha beta is highlighted.
  4. Type x.
  5. Choose File > Save, quit MarkText and open t.md again.

Repeat with each variant. Each file is alpha beta, one blank line, then the "Next block" lines (/ separates lines), except E, whose whole file is given below.

Variant Next block Expected result
A ***, or --- x, then the rule
B - item one / - item two, or 1. item one / 2. item two x, then the unchanged two-item list
C > quoted words x, then the quote
D next words x, then the paragraph next words
E front matter (file below) --- / x / ---, then next words
F | h1 | h2 | / | -- | -- | / | c1 | c2 | x, then the unchanged table
G - [ ] task one x, then the task list
H # next heading, or Next heading / === x, then the heading
I $$ / a+b / $$, or <div>hi</div> x, then the math or HTML block

E (triple-click alpha inside the front matter):

---
title: alpha
---

next words

Expected Behavior

Only the highlighted line is replaced by x and the next block is left unchanged (see the "Expected result" column). The screen, the unsaved marker and the saved file agree. Variant I already behaves this way.

Actual Behavior

The next block is merged into the typed line. The unsaved marker appears and the saved file matches the screen:

  • A: x*** (rule gone), or x---.
  • B: xitem one, then a list with only - item two (ordered: 1. item two).
  • C: xquoted words (quote gone). D: xnext words.
  • E: --- / xnext words / ---. The title line is gone and the body paragraph is now front matter.

The screen changes but the document does not:

  • F: alpha beta is replaced by an empty line with x above the table. G: alpha beta disappears and x is shown inside the task list.
  • No unsaved marker appears, File > Save writes the original file, and reopening shows alpha beta again.

Heading below (H): the triple-click highlights nothing, x is inserted before the text, and the file is saved as xalpha beta with the heading unchanged.

Screenshots / Logs

No error is shown.

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): Chromium ends a triple-click selection at offset 0 of the next block while the highlight covers only the line. The cross-block cut that runs on keydown (packages/muya/src/clipboard/index.ts) then merges what remains of the next block, which is all of it, into the line. When the selection ends on a node with no text (a table, a task checkbox), it cannot be mapped to blocks and the browser edits the DOM alone.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions