fix(input is now only forwarded in normal mode)

This commit is contained in:
Brooks Rady 2021-02-23 17:56:13 +00:00 committed by GitHub
commit a82cc8fbcb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 8 deletions

8
rust-toolchain.toml Normal file
View file

@ -0,0 +1,8 @@
# https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file
[toolchain]
# can be further pinned eg:
# date: "stable-2020-07-10"
# version: "nightly-1.0.0"
channel = "stable"
components = [ "rustfmt", "rust-src", "clippy", "rust-analysis"]
# targets = [ ]

View file

@ -39,6 +39,8 @@ pub enum Action {
CloseFocus, CloseFocus,
/// Create a new tab. /// Create a new tab.
NewTab, NewTab,
/// Do nothing.
NoOp,
/// Go to the next tab. /// Go to the next tab.
GoToNextTab, GoToNextTab,
/// Go to the previous tab. /// Go to the previous tab.

View file

@ -227,6 +227,7 @@ impl InputHandler {
.unwrap(); .unwrap();
self.command_is_executing.wait_until_pane_is_closed(); self.command_is_executing.wait_until_pane_is_closed();
} }
Action::NoOp => {}
} }
should_break should_break

View file

@ -165,15 +165,16 @@ pub fn key_to_actions(
mode: &InputMode, mode: &InputMode,
keybinds: &Keybinds, keybinds: &Keybinds,
) -> Vec<Action> { ) -> Vec<Action> {
if let Some(mode_keybinds) = keybinds.get(mode) { let mode_keybind_or_action = |action: Action| {
mode_keybinds keybinds
.get(mode)
.unwrap_or_else(|| unreachable!("Unrecognized mode: {:?}", mode))
.get(key) .get(key)
.cloned() .cloned()
// FIXME in command mode, unbound keystrokes should probably do nothing instead of .unwrap_or_else(|| vec![action])
// writing to the terminal. Will be easier to implement after a big refactor of the };
// input system (@categorille) match *mode {
.unwrap_or_else(|| vec![Action::Write(input)]) InputMode::Normal => mode_keybind_or_action(Action::Write(input)),
} else { _ => mode_keybind_or_action(Action::NoOp),
unreachable!("Unrecognized mode: {:?}", mode);
} }
} }