From 9db0321bff5ab424f2aed2c5ca471f61c84c58b8 Mon Sep 17 00:00:00 2001 From: Omnikar Date: Fri, 27 Oct 2023 22:21:45 -0400 Subject: [PATCH] Fix bug where `:h` would leave pending keys Using `:h` with a key that branches into other bindings, such as `g` or `z` would leave the inputted keys as pending, meaning that any following keypresses would register as if the looked-up keys had been typed first. --- helix-term/src/commands/typed.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 0cd62579d..a45d6e1b1 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -2490,9 +2490,13 @@ fn help(cx: &mut compositor::Context, args: &[Cow], event: PromptEvent) -> KeymapResult::NotFound | KeymapResult::Cancelled(_) => { Err(anyhow!("No command found for '{}'", arg)) } - KeymapResult::Pending(_) => Err(anyhow!( - "`:help` for branching keybinds is not yet supported." - )), + KeymapResult::Pending(_) => { + // Clear pending keys + keymaps.get(mode, crate::keymap::macros::key!(Esc)); + Err(anyhow!( + "`:help` for branching keybinds is not yet supported." + )) + } KeymapResult::MatchedSequence(_) => Err(anyhow!( "`:help` for sequence bindings is not yet supported." )),