Skip to content

Input Method (IME) fails to receive 'j' when 'j k' mapping is active in insertmode #36610

@wei-py

Description

@wei-py

Summary

When using an Input Method Editor (IME) for Chinese (or other CJK languages), typing a letter like j to start a composition (e.g., typing pinyin "jiang") fails to register the initial j if a keybinding like j k is configured to trigger vim::NormalBefore.

Zed Version and System Specs

🐞 GitHub Issue: Input Method (IME) fails to receive 'j' when 'j k' mapping is active in insert mode

Describe the bug
When using an Input Method Editor (IME) for Chinese (or other CJK languages), typing a letter like j to start a composition (e.g., typing pinyin "jiang") fails to register the initial j if a keybinding like j k is configured to trigger vim::NormalBefore.

This happens because Zed's keybinding system intercepts the j press immediately, waiting for a potential k to complete the chord, even during IME composition (compositionstart). As a result:

  • The IME never receives the j.
  • The user cannot start typing Chinese pinyin that begins with j.
  • This makes the editor nearly unusable with IMEs when j-prefixed chords are used.

This issue occurs in both insert mode and visual mode when the following keybindings are set.

To Reproduce

  1. Configure Zed with the following keybindings:
{
  "context": "Editor && vim_mode == insert",
  "bindings": {
    "j k": "vim::NormalBefore"
  }
},
{
  "context": "Editor && vim_mode == visual",
  "bindings": {
    "j k": "vim::NormalBefore"
  }
}
  1. Switch to a Chinese input method (e.g., Pinyin, Rime, Sogou).
  2. Enter insert mode and type j, intending to type a word like "你好" via pinyin (e.g., ni hao, or starting with jia).
  3. Observe that:
    • The j does not appear in the IME candidate window.
    • No composition starts.
    • After a short delay, the editor may exit insert mode if k is pressed next.

Expected Behavior

  • During IME composition (compositionstart), key chords like j k should be ignored or deferred.
  • The j key should be passed to the IME to begin composition.
  • Chord-based Vim exit bindings should not interfere with IME input.

Actual Behavior

  • The j key is consumed by the keybinding system.
  • IME does not receive the key, so composition fails.
  • User cannot type any pinyin starting with j.

Workarounds

  • Change the exit chord to a less common sequence (e.g., k j, f d, jj).
  • Avoid using common pinyin initials (j, q, x, z, c, s) as the first key in a chord.
  • Use Esc instead of a chord (recommended for IME users).

Possible Fix (Suggestion)
Zed should detect when an IME is active (compositionstart event) and:

  • Suspend or ignore chord-based keybindings during composition.
  • Only resume chord detection after compositionend.

This is consistent with how other editors (e.g., VS Code, Neovim with :help iminsert) handle IME + keybinding conflicts.

Environment

  • Zed Editor Version: [e.g., v0.145.1]
  • OS: [e.g., macOS 14, Windows 11, Ubuntu 22.04]
  • Input Method: [e.g., macOS Pinyin, Sogou, Rime, Google Pinyin]

Additional Context
This is a critical usability issue for non-English Vim users relying on IMEs. While changing the chord helps, the editor should respect IME semantics by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:controls/imearea:editorFeedback for code editing, formatting, editor iterations, etcarea:internationalizationFeedback for human language support, translations, etcarea:parity/vimFeedback for Vim parity featuresfrequency:uncommonBugs that happen for a small subset of users, special configurations, rare circumstances, etcpriority:P3Papercuts, minor issues with a clear workaround, cosmetic bugsstate:needs reproNeeds reproduction steps and/or someone to reproduce

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions