Words cannot properly type in after using double space + shift to change line in Chinese · Issue #3468 · marktext/marktext · GitHub
Skip to content

Words cannot properly type in after using double space + shift to change line in Chinese  #3468

Closed

Description

@for-ever-yang

Description

When using Chinese input method, I won't be able to type in first word in the new line after using double space + shift.
The first character will be eaten and not shown in the input method.

用两个空格+shift进行换行之后,中文输入法的第一个字母不会正常显示在输入法里。

  • Can you reproduce the issue?

Steps to reproduce

  1. Switch to Chinese input method: Pinyin - Simplified
  2. Use double space + shift to change to a new line
  3. type in whaterever words and issue shows

=================

  1. 使用中文简体输入法
  2. 用两个空格+shift进行换行
  3. 输入拼音,第一个字母会被吞掉,输入法中识别不到

Expected behavior:

The input method can properly read what I type.

输入法能正确读取我输入的字母拼音。

Actual behavior:

The first character cannot be read by input method.

第一个字母不能被输入法读取

Link to an example: [optional]

Screenshot

Versions

  • MarkText version: 0.17.1
  • Operating system: macOS Monterey 12.6 (M1 Pro chip)

Activity

  1. lindeer commented on Nov 24, 2022

    @lindeer

    on my arm64 linux machine, input drop down completely not show, maybe the support of input method has some issues?

    $ uname -ar
    Linux wesley-UOS 4.19.71-arm64-desktop #1 SMP PREEMPT Thu Jul 15 14:18:15 CST 2021 aarch64 GNU/Linux
    
  2. added
    🐛 bugSomething isn't working
    🪲 pri/majorBugs will affect your normal use of Mark Text, causing you unwilling or unable to continue using MT
    on May 16, 2026
  3. Jocs commented on Jun 23, 2026

    @Jocs
    Member

    Thank you for the detailed report. The MarkText editor engine has been fully rewritten since v0.17.1, and this specific issue was explicitly addressed in the new engine.

    In the current codebase (packages/muya/src/block/base/content.ts, lineBreakAutoPair at line 270), there is a dedicated guard that detects when a Shift+Enter soft/hard line break was just inserted (blockText.endsWith('\n')) and corrects the cursor offset before the input handler processes the first character of any subsequent IME composition. This prevents the "first character eaten" behavior.

    If you are still experiencing this on a recent build (0.18.0 or later), please reopen with the current version number and your OS/input method details. Closing as resolved by the engine migration.

  4. Jocs commented on Sep 10, 2026

    @Jocs
    Member

    Reopening: the June closure was based on lineBreakAutoPair's compositionend branch in the new engine, but that branch is unreachable — composeHandler forwards the raw CompositionEvent into inputHandler, and autoPair gates on isInputEvent ('inputType' in event), which every CompositionEvent fails. So the code cited as the fix never ran.

    The behaviour reported here also still reproduces in the old JS engine, so it was never engine-specific: a block whose text ends with \n renders that newline as the last thing in its DOM, the caret sits inside the newline's own text node, and Chromium will not sustain a composition there — it overwrites the newline and abandons the composition, so the input method never receives the keystroke that started the word.

    Captured from a real composition driven through CDP Input.imeSetComposition:

    compositionstart   blockText="第一行\n"   domText="第一行\n"
    input  d           domText="第一行d"        ← the newline is gone
    compositionstart   ← again: the composition restarted, 'd' is now plain text
    input  i / ie / i'er'hang                     ← the IME buffer no longer has the 'd'
    compositionend data="i 二行"
    

    Fixed in #5281.

  5. reopened this on Sep 10, 2026
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

    🪲 pri/majorBugs will affect your normal use of Mark Text, causing you unwilling or unable to continue using MT🐛 bugSomething isn't working🔭 area/editor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions