Files
zed/crates/which_key
Divyanshu Singh cffa8d94a8 which_key: Don't dismiss open modals when showing pending bindings (#66630)
## Summary

With which-key enabled, pausing in the middle of a multi-key binding
closes whatever modal is open. I hit this with vim mode in the expanded
commit editor: pressing `g` and waiting for the which-key popup closed
the editor. The same thing happens with `cmd-k` in pickers like Go to
Line, so their `cmd-k` chords can't be completed.

The cause is that the modal layer only holds one modal at a time, and
which-key opens as a modal. Before opening, it only checked whether a
which-key popup was already open, so any other modal got replaced.

I changed that check to skip the popup while any modal is open. The open
modal stays, and the chord still completes inside it. The trade-off is
that the popup isn't shown inside modals, but pending keys are still
shown in the status bar (by the pending keystrokes indicator, or by the
vim mode indicator in vim and Helix mode).

Closes #66068
Closes #66246

## Testing

- Added `test_which_key_does_not_replace_open_modal`, which opens a
modal, starts a chord, pauses, then completes it, and checks that the
modal is still open and the chord's action ran. It fails without the
fix.
- Added `test_which_key_shows_for_pending_chord` to make sure the popup
still shows when no modal is open.
- Tested manually on macOS with vim mode and which-key enabled.

Steps to reproduce:
1. Set `"vim_mode": true` and `"which_key": { "enabled": true,
"delay_ms": 1000 }`
2. Open the Git panel (`ctrl-shift-g`), click the commit message box,
and press `shift-escape`
3. Press `Escape`, then `g`, and wait a second
4. Before: the commit editor closes. After: it stays open.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Fixed which-key closing the commit editor and pickers when a multi-key
binding was pending

---------

Co-authored-by: Divyanshu Singh <177622442+divyanshus2404@users.noreply.github.com>
Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-11-11 13:02:28 +00:00
..