MacOS: Vim jj keybinding intercepts j key from CJK IME#1
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 027fabb30b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| && unsafe { is_ime_input_source_active() } | ||
| && with_input_handler(this, |input_handler| { | ||
| input_handler.query_accepts_text_input() | ||
| }) |
There was a problem hiding this comment.
Exclude terminal input handlers from IME-first printable keys
Because PlatformInputHandler::accepts_text_input() defaults to true (crates/gpui/src/platform.rs:1207-1209) and the terminal input handler does not override it (crates/terminal_view/src/terminal_element.rs:1444-1522), this new gate now routes every printable key through inputContext.handleEvent: whenever a non-ASCII IME is selected. In the terminal that reintroduces the behavior called out in the comment above: apps like less or terminal Vim will have plain j/k absorbed by the IME instead of receiving raw bytes, even when there is no marked text. Please scope this path to editor-style text inputs, or explicitly opt terminal handlers out.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 027fabb30b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| && !key_down_event.keystroke.modifiers.control | ||
| && !key_down_event.keystroke.modifiers.function | ||
| && !key_down_event.keystroke.modifiers.platform | ||
| && unsafe { is_ime_input_source_active() } |
There was a problem hiding this comment.
kTISPropertyInputSourceIsASCIICapable は「ASCII を入力できるか」を示すだけで、合成 IME かどうかは表しません。crates/gpui_macos/src/events.rs:425-430 でも扱っている Armenian/Ukrainian のような通常の非 ASCII キーボード配列でもここが真になり得るため、その場合は文字入力を受け付けるビューで printable key が毎回 inputContext.handleEvent に先回りされます。プレーンな配列入力はそこでそのまま YES になって doCommandBySelector: へ戻らないので、insert モードの複数打鍵など printable キーバインドが発火しなくなる回帰になります。
Useful? React with 👍 / 👎.
Context
There was an issue where CJK input could not be entered correctly when certain keys used during IME composition conflicted with custom keybindings while the CJK IME was enabled.
(In particular, in Vim mode, the
jjkeybinding in INSERT MODE could not be entered correctly.)This issue had already been fixed on Windows, but not on macOS (and judging from the code, it is likely also present on Linux, although this has not been verified).
In this change, we aligned the behavior with Windows.
Currently, on Windows, when the CJK ( or other ) IME is enabled, IME input is prioritized.
Following this behavior, we updated macOS to also prioritize IME input.
KeyboardInputModefalsetrueKeyboardInputModetruefalseKeyboardInputModefalsetrueKeyboardInputModefalsetrueKeyboardLayoutfalsefalseKeyboardLayoutfalsefalseKeyboardLayouttruefalse(Since similar approaches are used in tools like Vim and Neovim, we consider this policy to be appropriate.)
Fixes
Videos
before fix
before.mp4
after fix
after2.mp4
How to Review
This change modifies the gpui layer rather than Zed itself, so please verify the behavior at the gpui level, not just within Zed.
Self-Review Checklist
Release Notes:
jj