aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authora-kenji <aks.kenji@protonmail.com>2021-02-22 16:49:37 +0100
committera-kenji <aks.kenji@protonmail.com>2021-02-22 21:53:50 +0100
commitf3f23972ebd9041a1b9c5abf3e084d7ec5cc1be6 (patch)
treea28bfe5dcc218425b853c71fea1f385d4bf0b562 /src
parentRemove Target from toolchain file. (diff)
downloadsl0ppij-f3f23972ebd9041a1b9c5abf3e084d7ec5cc1be6.tar.gz
sl0ppij-f3f23972ebd9041a1b9c5abf3e084d7ec5cc1be6.tar.xz
sl0ppij-f3f23972ebd9041a1b9c5abf3e084d7ec5cc1be6.zip
fix(input) Write user input only in Normal mode
closes 184 Added the Action::NoOp from https://github.com/zellij-org/zellij/issues/184
Diffstat (limited to 'src')
-rw-r--r--src/common/input/actions.rs2
-rw-r--r--src/common/input/handler.rs1
-rw-r--r--src/common/input/keybinds.rs17
3 files changed, 12 insertions, 8 deletions
diff --git a/src/common/input/actions.rs b/src/common/input/actions.rs
index 7193b46e..00c18c1e 100644
--- a/src/common/input/actions.rs
+++ b/src/common/input/actions.rs
@@ -39,6 +39,8 @@ pub enum Action {
CloseFocus,
/// Create a new tab.
NewTab,
+ /// Do nothing.
+ NoOp,
/// Go to the next tab.
GoToNextTab,
/// Go to the previous tab.
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs
index 4d1e4f44..2a8c3bfa 100644
--- a/src/common/input/handler.rs
+++ b/src/common/input/handler.rs
@@ -227,6 +227,7 @@ impl InputHandler {
.unwrap();
self.command_is_executing.wait_until_pane_is_closed();
}
+ Action::NoOp => {}
}
should_break
diff --git a/src/common/input/keybinds.rs b/src/common/input/keybinds.rs
index 151d3495..c573a557 100644
--- a/src/common/input/keybinds.rs
+++ b/src/common/input/keybinds.rs
@@ -165,15 +165,16 @@ pub fn key_to_actions(
mode: &InputMode,
keybinds: &Keybinds,
) -> Vec<Action> {
- if let Some(mode_keybinds) = keybinds.get(mode) {
- mode_keybinds
+ let mode_keybind_or_action = |action: Action| {
+ keybinds
+ .get(mode)
+ .unwrap_or_else(|| unreachable!("Unrecognized mode: {:?}", mode))
.get(key)
.cloned()
- // FIXME in command mode, unbound keystrokes should probably do nothing instead of
- // writing to the terminal. Will be easier to implement after a big refactor of the
- // input system (@categorille)
- .unwrap_or_else(|| vec![Action::Write(input)])
- } else {
- unreachable!("Unrecognized mode: {:?}", mode);
+ .unwrap_or_else(|| vec![action])
+ };
+ match *mode {
+ InputMode::Normal => mode_keybind_or_action(Action::Write(input)),
+ _ => mode_keybind_or_action(Action::NoOp),
}
}