Skip to content

gpui: Complete pending key bindings before IME input - #61270

Merged
tomhoule merged 2 commits into
zed-industries:mainfrom
GoldStrikeArch:fix/pending-key-input-during-ime-input
Jul 29, 2026
Merged

gpui: Complete pending key bindings before IME input#61270
tomhoule merged 2 commits into
zed-industries:mainfrom
GoldStrikeArch:fix/pending-key-input-during-ime-input

Conversation

@GoldStrikeArch

@GoldStrikeArch GoldStrikeArch commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Objective

Solution

  • Stop preferring IME-first printable input while a valid multi-stroke keybinding is pending. This allows the next printable keystroke to reach GPUI and complete the binding.
  • Consider pending input active only when it belongs to the window's current focus. This prevents stale pending state after a focus change or blur from bypassing normal IME handling.
  • Preserve the existing macOS active-composition path, so marked text, candidate selection, and composition commands continue to reach NSTextInputContext first.

Testing

Manually tested on macOS using Apple’s built-in Japanese–Romaji/Hiragana input source with a ctrl-x k keybinding. Also added regression test for pending keybinding routing.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed multi-stroke keybindings not completing when using an IME on macOS.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 18, 2026
@ChristopherBiscardi ChristopherBiscardi added the area:gpui GPUI rendering framework support label Jul 21, 2026
@opsnull

opsnull commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Thanks @GoldStrikeArch! This PR also resolved my Chinese IME problems.

chenwei-94 pushed a commit to chenwei-94/zed that referenced this pull request Jul 28, 2026
# Objective

Fixes zed-industries#59129.

`vim::HelixJumpToWord` currently treats its two-character target labels
as text input. When an IME is active, the printable label keys can
therefore enter the IME composition window instead of completing the
jump.

## Solution

- Treat an active Helix jump as command input rather than character
input, preventing the platform input handler from preferring the IME for
its label keys.
- After normal keybinding resolution, handle action-less, unmodified
label keydowns directly from the keystroke's ASCII-equivalent key. This
preserves label matching on non-ASCII keyboard layouts while leaving
Escape, custom bindings, and Ctrl/Alt/Cmd/Function shortcuts untouched.
- Stop propagation after consuming a label key so the platform does not
subsequently forward it to the IME.
- Keep the existing committed-text handling as a fallback for other
input paths.

This is complementary to zed-industries#61270: that PR handles pending GPUI keybinding
chords before IME input, while this change handles Helix jump labels
after the initiating action has resolved. The changes are also
file-disjoint.

## Testing

- Added a regression test using the issue's `s` → `vim::HelixJumpToWord`
binding. The test verifies that:
  - no GPUI keybinding chord is pending;
  - Helix jump does not accept text input or prefer the IME;
  - both raw label keydown events are consumed; and
  - the expected jump completes.

- Manually tested on macOS with both ABC and Japanese Romaji input
sources.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed Helix jump-to-word label input being intercepted by IMEs.
@tomhoule tomhoule self-assigned this Jul 28, 2026
GoldStrikeArch and others added 2 commits July 29, 2026 14:13
`has_pending_keystrokes` only reports pending input belonging to the
current focus, but `pending_input_keystrokes` still returned the
keystrokes of input left over from a previous focus, so the two
disagreed after a blur. Route both through one accessor so that they
cannot drift apart.

Also document that `query_prefers_ime_for_printable_keys` is gated on
pending input rather than purely delegating to the handler, as its name
suggests.
@tomhoule
tomhoule force-pushed the fix/pending-key-input-during-ime-input branch from 02cdb8d to 0623a44 Compare July 29, 2026 13:14

@tomhoule tomhoule left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can also confirm the fix works from manual testing, and I think the way it works is sound. Thank you for the contribution!

@tomhoule
tomhoule added this pull request to the merge queue Jul 29, 2026
Merged via the queue into zed-industries:main with commit dc1e815 Jul 29, 2026
36 checks passed
@GoldStrikeArch
GoldStrikeArch deleted the fix/pending-key-input-during-ime-input branch July 29, 2026 15:38
AtlantisPleb pushed a commit to OpenAgentsInc/omega that referenced this pull request Jul 30, 2026
…61270)

# Objective

- Fix multi-stroke keybindings such as `ctrl-x k` being intercepted by
the macOS Japanese IME before GPUI can complete the binding.
- Preserve IME-first handling for ordinary Japanese text input and
active marked-text composition.
- Fixes zed-industries#56043.

## Solution

- Stop preferring IME-first printable input while a valid multi-stroke
keybinding is pending. This allows the next printable keystroke to reach
GPUI and complete the binding.
- Consider pending input active only when it belongs to the window's
current focus. This prevents stale pending state after a focus change or
blur from bypassing normal IME handling.
- Preserve the existing macOS active-composition path, so marked text,
candidate selection, and composition commands continue to reach
`NSTextInputContext` first.

## Testing

Manually tested on macOS using Apple’s built-in Japanese–Romaji/Hiragana
input source with a `ctrl-x k` keybinding. Also added regression test
for pending keybinding routing.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed multi-stroke keybindings not completing when using a Japanese
IME on macOS.

---------

Co-authored-by: Tom Houlé <tom@tomhoule.com>
(cherry picked from commit dc1e815)
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
# Objective

Fixes zed-industries#59129.

`vim::HelixJumpToWord` currently treats its two-character target labels
as text input. When an IME is active, the printable label keys can
therefore enter the IME composition window instead of completing the
jump.

## Solution

- Treat an active Helix jump as command input rather than character
input, preventing the platform input handler from preferring the IME for
its label keys.
- After normal keybinding resolution, handle action-less, unmodified
label keydowns directly from the keystroke's ASCII-equivalent key. This
preserves label matching on non-ASCII keyboard layouts while leaving
Escape, custom bindings, and Ctrl/Alt/Cmd/Function shortcuts untouched.
- Stop propagation after consuming a label key so the platform does not
subsequently forward it to the IME.
- Keep the existing committed-text handling as a fallback for other
input paths.

This is complementary to zed-industries#61270: that PR handles pending GPUI keybinding
chords before IME input, while this change handles Helix jump labels
after the initiating action has resolved. The changes are also
file-disjoint.

## Testing

- Added a regression test using the issue's `s` → `vim::HelixJumpToWord`
binding. The test verifies that:
  - no GPUI keybinding chord is pending;
  - Helix jump does not accept text input or prefer the IME;
  - both raw label keydown events are consumed; and
  - the expected jump completes.

- Manually tested on macOS with both ABC and Japanese Romaji input
sources.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed Helix jump-to-word label input being intercepted by IMEs.
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…61270)

# Objective

- Fix multi-stroke keybindings such as `ctrl-x k` being intercepted by
the macOS Japanese IME before GPUI can complete the binding.
- Preserve IME-first handling for ordinary Japanese text input and
active marked-text composition.
- Fixes zed-industries#56043.

## Solution

- Stop preferring IME-first printable input while a valid multi-stroke
keybinding is pending. This allows the next printable keystroke to reach
GPUI and complete the binding.
- Consider pending input active only when it belongs to the window's
current focus. This prevents stale pending state after a focus change or
blur from bypassing normal IME handling.
- Preserve the existing macOS active-composition path, so marked text,
candidate selection, and composition commands continue to reach
`NSTextInputContext` first.

## Testing

Manually tested on macOS using Apple’s built-in Japanese–Romaji/Hiragana
input source with a `ctrl-x k` keybinding. Also added regression test
for pending keybinding routing.


## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed multi-stroke keybindings not completing when using a Japanese
IME on macOS.

---------

Co-authored-by: Tom Houlé <tom@tomhoule.com>
HyacinthHaru pushed a commit to HyacinthHaru/z3rm that referenced this pull request Aug 16, 2026
…61270)

# Objective

- Fix multi-stroke keybindings such as `ctrl-x k` being intercepted by
the macOS Japanese IME before GPUI can complete the binding.
- Preserve IME-first handling for ordinary Japanese text input and
active marked-text composition.
- Fixes zed-industries#56043.

## Solution

- Stop preferring IME-first printable input while a valid multi-stroke
keybinding is pending. This allows the next printable keystroke to reach
GPUI and complete the binding.
- Consider pending input active only when it belongs to the window's
current focus. This prevents stale pending state after a focus change or
blur from bypassing normal IME handling.
- Preserve the existing macOS active-composition path, so marked text,
candidate selection, and composition commands continue to reach
`NSTextInputContext` first.

## Testing

Manually tested on macOS using Apple’s built-in Japanese–Romaji/Hiragana
input source with a `ctrl-x k` keybinding. Also added regression test
for pending keybinding routing.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed multi-stroke keybindings not completing when using a Japanese
IME on macOS.

---------

Co-authored-by: Tom Houlé <tom@tomhoule.com>
(cherry picked from commit dc1e815)
playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
# Objective

Fixes zed-industries#59129.

`vim::HelixJumpToWord` currently treats its two-character target labels
as text input. When an IME is active, the printable label keys can
therefore enter the IME composition window instead of completing the
jump.

## Solution

- Treat an active Helix jump as command input rather than character
input, preventing the platform input handler from preferring the IME for
its label keys.
- After normal keybinding resolution, handle action-less, unmodified
label keydowns directly from the keystroke's ASCII-equivalent key. This
preserves label matching on non-ASCII keyboard layouts while leaving
Escape, custom bindings, and Ctrl/Alt/Cmd/Function shortcuts untouched.
- Stop propagation after consuming a label key so the platform does not
subsequently forward it to the IME.
- Keep the existing committed-text handling as a fallback for other
input paths.

This is complementary to zed-industries#61270: that PR handles pending GPUI keybinding
chords before IME input, while this change handles Helix jump labels
after the initiating action has resolved. The changes are also
file-disjoint.

## Testing

- Added a regression test using the issue's `s` → `vim::HelixJumpToWord`
binding. The test verifies that:
  - no GPUI keybinding chord is pending;
  - Helix jump does not accept text input or prefer the IME;
  - both raw label keydown events are consumed; and
  - the expected jump completes.

- Manually tested on macOS with both ABC and Japanese Romaji input
sources.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed Helix jump-to-word label input being intercepted by IMEs.
playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
…61270)

# Objective

- Fix multi-stroke keybindings such as `ctrl-x k` being intercepted by
the macOS Japanese IME before GPUI can complete the binding.
- Preserve IME-first handling for ordinary Japanese text input and
active marked-text composition.
- Fixes zed-industries#56043.

## Solution

- Stop preferring IME-first printable input while a valid multi-stroke
keybinding is pending. This allows the next printable keystroke to reach
GPUI and complete the binding.
- Consider pending input active only when it belongs to the window's
current focus. This prevents stale pending state after a focus change or
blur from bypassing normal IME handling.
- Preserve the existing macOS active-composition path, so marked text,
candidate selection, and composition commands continue to reach
`NSTextInputContext` first.

## Testing

Manually tested on macOS using Apple’s built-in Japanese–Romaji/Hiragana
input source with a `ctrl-x k` keybinding. Also added regression test
for pending keybinding routing.


## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed multi-stroke keybindings not completing when using a Japanese
IME on macOS.

---------

Co-authored-by: Tom Houlé <tom@tomhoule.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpui GPUI rendering framework support cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2-stroke keybindings (e.g., ctrl-x k) fail when macOS Input Method is ON since v0.230.0

4 participants