Skip to content

[Bug] Shift+Enter soft line break is lost when the next text is typed with a CJK IME #5279

Closed

Description

@Jocs

Description

Pressing Shift+Enter inserts a soft line break (\n) inside the current paragraph. When the text typed right after that break is committed through a CJK IME (Chinese pinyin in my case), the \n is silently dropped and the two lines end up merged into one.

Typing the same text with a plain keyboard layout (no IME) keeps the soft line break, so the problem is specific to the IME commit path.

Steps to Reproduce

  1. Open a new document in the WYSIWYG editor.

  2. Type 第一行:

    第一行
  3. Press Shift+Enter. The caret moves to a new line inside the same paragraph:

    第一行
    |
  4. With a Chinese IME active, type 第二行 and confirm the candidate.

Expected Behavior

The soft line break survives and the paragraph contains two lines:

第一行
第二行

Actual Behavior

The soft line break disappears and everything collapses onto one line:

第一行di 二行

Screenshots / Logs

No screenshot. Below is a code-reading hypothesis on develop @ 6ca82255 (not verified at runtime — the IME commit path is hard to drive headlessly).

lineBreakAutoPair() (packages/muya/src/block/base/content.ts:297) is what re-inserts the trailing \n that Chromium drops when text is typed immediately after a soft break, and it is written to cover the IME commit as well (content.ts:309):

&& (event.inputType === 'insertText' || event.type === 'compositionend')

However, it is only reachable through Content.autoPair(), which returns early before ever getting there (content.ts:631):

if (!isInputEvent(event) || !oldStart)
    return { text, needRender };

isInputEvent() is 'inputType' in event (packages/muya/src/utils/index.ts:402), and a CompositionEvent does not expose inputType:

inputType in CompositionEvent: false

composeHandler() forwards the raw compositionend event into inputHandler() (content.ts:601-609, "the compose event will not cause input event, So need call inputHandler by ourself"). So on the IME path autoPair() hands back the DOM text unchanged, the compositionend branch of lineBreakAutoPair() is effectively dead code, and the \n Chromium dropped is never restored.

Possibly related, but a different symptom: #3468 (first character eaten after a Shift+Enter break, closed as fixed by the engine rewrite). Here no character is lost — the line break itself is.

Operating System

macOS

MarkText Version

0.20.0-dev (develop @ 6ca82255)

OS Version

macOS 27.0

Reproducibility

  • I can reliably reproduce this issue

Activity

  1. added
    🐛 bug
    🚧 needs triage
    on Sep 10, 2026
  2. Jocs commented on Sep 10, 2026

    @Jocs
    MemberAuthor

    Code block has the same issue.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions