Skip to content

Japanese IME composition duplicated when eisuu key ends composition #5778

@kiki-ki

Description

@kiki-ki

When using the Japanese IME on macOS, ending composition by pressing the eisuu (英数) key — instead of Enter — causes the composed text to be duplicated.

This is a very common setup among Japanese Mac users: Karabiner-Elements remaps the left Command key (when pressed alone) to send japanese_eisuu, enabling quick IME toggling. This is one of the most popular Karabiner configurations in Japan.

Details

  • Browser and browser version: Electron 34.x (VS Code 1.112.0)
  • OS version: macOS 15 (Darwin 23.1.0, arm64)
  • xterm.js version: @xterm/xterm 6.1.0-beta.191 (bundled with VS Code 1.112.0)

Steps to reproduce

  1. On macOS, enable the Japanese IME
  2. Install Karabiner-Elements and configure: left Command (alone) → japanese_eisuu
  3. Open VS Code's integrated terminal
  4. Type Japanese text (e.g. type konnichiha to compose "こんにちは")
  5. Press left Command to confirm composition and switch to English input

Expected: "こんにちは" is committed once
Actual: "こんにちはこんにちは" — the text is duplicated

Notes

  • Pressing Enter to confirm composition first, then switching input source → no duplication
  • Using an external native terminal (e.g. Ghostty) → no duplication
  • The issue is not specific to any particular TUI application running inside the terminal

Probable cause

In CompositionHelper.ts, when a non-229 keyCode (such as japanese_eisuu) arrives while _isComposing is true:

  1. keydown() calls _finalizeComposition(false) — sends composed text immediately
  2. The browser then fires compositionend → calls _finalizeComposition(true) — sends composed text again via setTimeout
  3. Both paths emit the same text, resulting in duplication

Native terminal emulators do not have this issue because they use the OS-level IME framework directly, without going through DOM composition events.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions