gpui: Complete pending key bindings before IME input - #61270
Merged
tomhoule merged 2 commits intoJul 29, 2026
Merged
Conversation
5 tasks
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.
`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
force-pushed
the
fix/pending-key-input-during-ime-input
branch
from
July 29, 2026 13:14
02cdb8d to
0623a44
Compare
tomhoule
approved these changes
Jul 29, 2026
tomhoule
left a comment
Contributor
There was a problem hiding this comment.
I can also confirm the fix works from manual testing, and I think the way it works is sound. Thank you for the contribution!
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
ctrl-x kbeing intercepted by the macOS Japanese IME before GPUI can complete the binding.Solution
NSTextInputContextfirst.Testing
Manually tested on macOS using Apple’s built-in Japanese–Romaji/Hiragana input source with a
ctrl-x kkeybinding. Also added regression test for pending keybinding routing.Self-Review Checklist:
Release Notes: