diff options
Diffstat (limited to 'src/input/keybindings.rs')
| -rw-r--r-- | src/input/keybindings.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/input/keybindings.rs b/src/input/keybindings.rs index d56de80c..9ffce2ee 100644 --- a/src/input/keybindings.rs +++ b/src/input/keybindings.rs @@ -52,6 +52,7 @@ pub(crate) enum KeybindAction { SplitHorizontal, ClosePane, EditScrollback, + ClearPane, CopyMode, Zoom, EnterResizeMode, @@ -120,6 +121,7 @@ pub(crate) fn resolve_non_indexed_action( (&keybinds.close_tab, KeybindAction::CloseTab), (&keybinds.rename_pane, KeybindAction::RenamePane), (&keybinds.edit_scrollback, KeybindAction::EditScrollback), + (&keybinds.clear_pane, KeybindAction::ClearPane), (&keybinds.copy_mode, KeybindAction::CopyMode), (&keybinds.focus_pane_left, KeybindAction::FocusPaneLeft), (&keybinds.focus_pane_down, KeybindAction::FocusPaneDown), @@ -259,6 +261,40 @@ mod tests { use super::*; #[test] + fn clear_pane_is_unbound_by_default_and_configurable() { + assert!(crate::config::Config::default() + .keybinds() + .clear_pane + .bindings + .is_empty()); + let config: crate::config::Config = + toml::from_str("[keys]\nclear_pane = [\"super+k\", \"prefix+ctrl+k\"]").unwrap(); + assert!(config.collect_diagnostics().is_empty()); + let keybinds = config.keybinds(); + assert!(matches!( + resolve_direct_binding( + &keybinds, + &TerminalKey::new(KeyCode::Char('k'), KeyModifiers::SUPER) + ), + Some(KeybindMatch::Action(KeybindAction::ClearPane)) + )); + assert!(matches!( + resolve_prefix_binding( + &keybinds, + &TerminalKey::new(KeyCode::Char('k'), KeyModifiers::CONTROL) + ), + Some(KeybindMatch::Action(KeybindAction::ClearPane)) + )); + assert!(matches!( + resolve_prefix_binding( + &keybinds, + &TerminalKey::new(KeyCode::Char('k'), KeyModifiers::SHIFT) + ), + Some(KeybindMatch::Action(KeybindAction::SwapPaneUp)) + )); + } + + #[test] fn one_shared_resolver_handles_direct_prefix_and_indexed_bindings() { let keybinds = Keybinds { next_tab: crate::config::ActionKeybinds::direct("ctrl+n"), |
