From 497b7f3af8bf514a2156f88b38318b1b3b0befbd Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 3 May 2023 22:05:30 -0400 Subject: [PATCH] Move changes to handle_keymap_event --- helix-term/src/ui/editor.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index ba765960e..1c00b436b 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -830,17 +830,23 @@ impl EditorView { last_mode = current_mode; }; - match &key_result { + match key_result { KeymapResult::Matched(command) => { - execute_command(command); + execute_command(&command); } KeymapResult::Pending(node) => cxt.editor.autoinfo = Some(node.infobox()), KeymapResult::MatchedSequence(commands) => { for command in commands { - execute_command(command); + execute_command(&command); } } - KeymapResult::NotFound | KeymapResult::Cancelled(_) => return Some(key_result), + KeymapResult::NotFound => return Some(key_result), + KeymapResult::Cancelled(mut pending) => { + if !matches!(self.keymaps.get(mode, event), KeymapResult::NotFound) { + pending.pop(); + } + return Some(KeymapResult::Cancelled(pending)); + } } None } @@ -853,8 +859,7 @@ impl EditorView { commands::insert::insert_char(cx, ch) } } - KeymapResult::Cancelled(mut pending) => { - let last_evt = pending.pop().unwrap(); + KeymapResult::Cancelled(pending) => { for ev in pending { match ev.char() { Some(ch) => commands::insert::insert_char(cx, ch), @@ -867,14 +872,6 @@ impl EditorView { } } } - match self.handle_keymap_event(Mode::Insert, cx, last_evt) { - Some(KeymapResult::NotFound) => { - if let Some(ch) = last_evt.char() { - commands::insert::insert_char(cx, ch) - } - } - _ => (), - } } _ => unreachable!(), }