which_key: Add a pending key binding indicator (#63343)
This PR makes Zed's one-second key binding delay visible. Say both ctrl-w and ctrl-w left have bindings. After you press ctrl-w, Zed waits to see whether left follows. The PR shows that wait in the status bar with a countdown. Hovering the indicator shows which bindings can still match. It also adds a setting to hide the indicator. It does not change how Zed resolves key bindings. <img height="100" alt="dyn-db84a840272e2f6250a3f527a59b1efd" src="https://github.com/user-attachments/assets/e42c6a6c-4677-499f-a1d3-835960ebb21a" /> <br/> <img height="100" alt="dyn-8012278d030b41bc8ebfae1540504eff" src="https://github.com/user-attachments/assets/250928d5-f913-40f0-9068-00ccb5cdf59f" /> <br/> <img height="100" alt="file-5e6ffa90944faa294e7870f471b4e65b" src="https://github.com/user-attachments/assets/c250e6eb-a269-4e2c-a5a0-0be9b5006f99" /> Release Notes: - Added a status bar countdown for pending multi-stroke key bindings. --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
1 parent
a47324bb2b
commit
d4424eec68
21 files changed
+2269
-287
No files matched your search
@@ -175,6 +175,25 @@ The other kind of conflict that arises is when you have two bindings, one of whi
|
||||
|
||||
When this happens, and both bindings are active in the current context, Zed will wait for 1 second after you type `ctrl-w` to see if you're about to type `left`. If you don't type anything, or if you type a different key, then `DeleteToNextWordEnd` will be triggered. If you do, then `DeleteToEndOfLine` will be triggered.
|
||||
|
||||
Zed can also wait before inserting printable text when it might begin a multi-stroke binding. For example, with a `j k` binding, typing `j` waits briefly for `k`; otherwise, `j` is inserted after the timeout.
|
||||
|
||||
Whenever pending input has a timeout, a countdown indicator with the pending keystrokes is shown in the status bar. Hovering it lists the bindings that could still match and pauses the timeout so you can read them. The timeout resumes with the same remaining duration when the pointer leaves. The indicator can be hidden with `{"status_bar": {"pending_keystrokes_indicator": false}}`. Vim and Helix modes continue to use their existing pending-key indicator instead.
|
||||
|
||||
To also use the larger which-key menu, open the Settings Editor and search for
|
||||
`Show Which-key Menu`. The pending keystrokes indicator remains visible when the
|
||||
menu is enabled, and hovering it still pauses the timeout, but its binding list
|
||||
popover is disabled. Or add this to your settings.json:
|
||||
|
||||
```json [settings]
|
||||
{
|
||||
"which_key": {
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Set `which_key.delay_ms` to change how long Zed waits before opening the menu.
|
||||
|
||||
### Non-QWERTY keyboards
|
||||
|
||||
Zed's support for non-QWERTY keyboards is still a work in progress.
|
||||
|
||||
@@ -1859,13 +1859,25 @@ Positive `integer` value between 1 and 32. Values outside of this range will be
|
||||
```json [settings]
|
||||
{
|
||||
"status_bar": {
|
||||
"show_active_file": false,
|
||||
"active_language_button": true,
|
||||
"cursor_position_button": true,
|
||||
"line_endings_button": false
|
||||
"line_endings_button": false,
|
||||
"active_encoding_button": "non_utf8",
|
||||
"pending_keystrokes_indicator": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Options**
|
||||
|
||||
- `show_active_file`: Whether to show the name of the active file in the status bar
|
||||
- `active_language_button`: Whether to show the active language button (clicking it opens the language selector)
|
||||
- `cursor_position_button`: Whether to show the cursor position button (clicking it opens the go-to-line/column input)
|
||||
- `line_endings_button`: Whether to show the active line endings button (clicking it opens the line-ending selector)
|
||||
- `active_encoding_button`: When to show the active encoding button: `"enabled"`, `"disabled"`, or `"non_utf8"` (only for encodings other than UTF-8 without BOM)
|
||||
- `pending_keystrokes_indicator`: Whether to show an indicator with a countdown while timed multi-stroke input is pending. Hovering the indicator pauses the timeout. Its binding preview popover is disabled when the which-key popup is enabled (see [key bindings](../key-bindings.md#precedence))
|
||||
|
||||
There is an experimental setting that completely hides the status bar. This causes major usability problems (you will be unable to use many of Zed's features), but is provided for those who value screen real-estate above all else.
|
||||
|
||||
```json
|
||||
@@ -5293,6 +5305,26 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a
|
||||
- Setting: `vim_mode`
|
||||
- Default: `false`
|
||||
|
||||
## Which-key Menu
|
||||
|
||||
- Description: Show matching bindings while a multi-stroke binding is pending.
|
||||
- Setting: `which_key`
|
||||
- Default:
|
||||
|
||||
```json [settings]
|
||||
{
|
||||
"which_key": {
|
||||
"enabled": false,
|
||||
"delay_ms": 1000
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Options**
|
||||
|
||||
- `enabled`: Whether to show the which-key menu. When enabled, the pending keystrokes indicator remains visible, but its binding preview popover is disabled.
|
||||
- `delay_ms`: How long Zed waits before showing the menu, in milliseconds.
|
||||
|
||||
## When Closing With No Tabs
|
||||
|
||||
- Description: Whether the window should be closed when using 'close active item' on a window with no tabs
|
||||
|
||||
@@ -358,7 +358,12 @@ TBD: Centered layout related settings
|
||||
// Show/hide a button that displays the buffer's character encoding.
|
||||
// If set to "non_utf8", the button is hidden only for UTF-8 without BOM.
|
||||
// Defaults to "non_utf8".
|
||||
"active_encoding_button": "non_utf8"
|
||||
"active_encoding_button": "non_utf8",
|
||||
// Show/hide an indicator with a countdown while timed multi-stroke
|
||||
// input is pending. Hovering it pauses the timeout. Unless the which-key
|
||||
// menu is enabled, hovering also lists the bindings that could still match.
|
||||
// Defaults to true.
|
||||
"pending_keystrokes_indicator": true
|
||||
},
|
||||
"global_lsp_settings": {
|
||||
// Show/hide the LSP button in the status bar.
|
||||
|
||||
Reference in new issue
Block a user