# gpui: Only time out multi-stroke bindings when current prefix matches \(\#42659\) · gitcafe/zed

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

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

Visibility: public

Requested revision: b3ebcef5c68387176bd7e3d9d9592e4612e5eb9a

Requested commit: b3ebcef5c68387176bd7e3d9d9592e4612e5eb9a

Commit: b3ebcef5c68387176bd7e3d9d9592e4612e5eb9a

Tree: 2eb5083be903497d5348ecf2acbf378e5cc67c2d

Author: Xipeng Jin

Committer: GitHub

## Message

```
gpui: Only time out multi-stroke bindings when current prefix matches (#42659)

Part One for Resolving #10910

### Summary
Typing prefix (partial keybinding) will behave like Vim. No timeout
until you either finish the sequence or hit Escape, while ambiguous
sequences still auto-resolve after 1s.

### Description
This follow-up tweaks the which-key system first part groundwork so our
timeout behavior matches Vim’s expectations. Then we can implement the
UI part in the next step (reference latest comments in
https://github.com/zed-industries/zed/pull/34798)
- `DispatchResult` now reports when the current keystrokes are already a
complete binding in the active context stack (`pending_has_binding`). We
only start the 1s flush timer in that case. Pure prefixes or sequences
that only match in other contexts—stay pending indefinitely, so
leader-style combos like `space f g` no longer evaporate after a second.
- `Window::dispatch_key_event` cancels any prior timer before scheduling
a new one and only spawns the background flush task when
`pending_has_binding` is true. If there’s no matching binding, we keep
the pending keystrokes and rely on an explicit Escape or more typing to
resolve them.

Release Notes:

- Fixed multi-stroke keybindings so only ambiguous prefixes auto-trigger
after 1 s; unmatched prefixes now stay pending until canceled, matching
Vim-style leader behavior.
```

## Parents

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

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