aboutsummaryrefslogtreecommitdiff
path: root/src/input
diff options
context:
space:
mode:
authorJJ Liebig <jonathan.liebig@gmail.com>2026-09-28 11:58:09 +0200
committerGitHub <noreply@github.com>2026-09-28 11:58:09 +0200
commit7f89b11a11160874ba89f3be7c64b29960bd2df3 (patch)
tree0e875b3fbbe5a701cfb0182bda0ce0994267584c /src/input
parent0d5d6f1f317e238c8297076bc6ab5c3a0cd56283 (diff)
feat: support multiple prefix keys (#4653)
* feat: support multiple prefix keys keys.prefix accepts an array in addition to a single string so one config can define several prefix keys. Every configured prefix enters the same prefix mode, and the help panel lists them all. Published keybinding profiles keep the primary prefix as a scalar and carry the rest in an optional extra_prefixes field so older clients keep working with the primary prefix. * fix: reject an empty prefix list on reload An explicitly empty keys.prefix array now stays empty through config parsing so validation rejects it and a reload keeps the current keybindings instead of silently falling back to ctrl+b.
Diffstat (limited to 'src/input')
-rw-r--r--src/input/keybind_help.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/input/keybind_help.rs b/src/input/keybind_help.rs
index 2f89b861..cb1fdb99 100644
--- a/src/input/keybind_help.rs
+++ b/src/input/keybind_help.rs
@@ -63,13 +63,13 @@ fn indexed_range_prefix(bindings: &[IndexedKeybind]) -> Option<&str> {
pub(crate) fn keybind_help_groups(
keybinds: &Keybinds,
- prefix: (crossterm::event::KeyCode, crossterm::event::KeyModifiers),
+ prefixes: &[crate::config::KeyCombo],
) -> Vec<KeybindHelpGroup> {
let mut groups = vec![
(
"global",
vec![
- entry(crate::config::format_key_combo(prefix), "prefix mode"),
+ entry(crate::config::format_prefix_combos(prefixes), "prefix mode"),
entry(binding_label(&keybinds.help), "keybinds"),
entry(binding_label(&keybinds.settings), "settings"),
entry(binding_label(&keybinds.detach), "detach"),
@@ -267,4 +267,18 @@ mod tests {
assert_eq!(filtered[0].1[0].1, "close pane");
assert!(filter_keybind_help_groups(groups(), "panes").is_empty());
}
+
+ #[test]
+ fn help_lists_every_configured_prefix() {
+ let groups = keybind_help_groups(
+ &Keybinds::default(),
+ &[
+ (KeyCode::Char(' '), KeyModifiers::CONTROL),
+ (KeyCode::Char('s'), KeyModifiers::CONTROL),
+ ],
+ );
+ let global = &groups[0].1;
+ assert_eq!(global[0].0, "ctrl+space / ctrl+s");
+ assert_eq!(global[0].1, "prefix mode");
+ }
}