# gpui: Complete pending key bindings before IME input \(\#61270\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/dc1e815e47835095748cbb036541992abd9ac826)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: dc1e815e47835095748cbb036541992abd9ac826

Requested commit: dc1e815e47835095748cbb036541992abd9ac826

Commit: dc1e815e47835095748cbb036541992abd9ac826

Tree: 1dc44a5fc7b5ec5ac6709591fd0871ece9b4e7f2

Author: Mikhail Pertsev

Committer: GitHub

## Message

```
gpui: Complete pending key bindings before IME input (#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 #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>
```

## Parents

- [12a19dccef81f85fa2ca07aee37499f659ed0942](https://git.cafe/gitcafe/zed/commit/12a19dccef81f85fa2ca07aee37499f659ed0942?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/dc1e815e47835095748cbb036541992abd9ac826?format=markdown)
