From 930b4a58664067f4132c568e384d7abd281f721b Mon Sep 17 00:00:00 2001 From: icanhazcheeze <86279884+icanhazcheeze@users.noreply.github.com> Date: Sun, 29 May 2022 04:14:09 +0000 Subject: [PATCH] enable entering insert mode through command sequence --- helix-term/src/ui/editor.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 85028e2ff123..57204b691a5e 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -33,7 +33,7 @@ use tui::buffer::Buffer as Surface; pub struct EditorView { pub keymaps: Keymaps, on_next_key: Option>, - last_insert: (commands::MappableCommand, Vec), + last_insert: (Vec, Vec), pub(crate) completion: Option, spinners: ProgressSpinners, } @@ -56,7 +56,7 @@ impl EditorView { Self { keymaps, on_next_key: None, - last_insert: (commands::MappableCommand::normal_mode, Vec::new()), + last_insert: (vec![commands::MappableCommand::normal_mode], Vec::new()), completion: None, spinners: ProgressSpinners::default(), } @@ -859,8 +859,10 @@ impl EditorView { } // special handling for repeat operator (key!('.'), _) if self.keymaps.pending().is_empty() => { - // first execute whatever put us into insert mode - self.last_insert.0.execute(cxt); + for cmd in self.last_insert.0.iter_mut() { + // first execute whatever put us into insert mode + cmd.execute(cxt); + } // then replay the inputs for key in self.last_insert.1.clone() { match key { @@ -1287,8 +1289,10 @@ impl Component for EditorView { // we can repeat the side effect. self.last_insert.0 = match self.keymaps.get(mode, key) { - KeymapResult::Matched(command) => command, - // FIXME: insert mode can only be entered through single KeyCodes + KeymapResult::Matched(command) => vec![command], + KeymapResult::MatchedSequence(commands) => commands, + + // FIXME: insert mode can only be entered through single KeyCodes. _ => unimplemented!(), }; self.last_insert.1.clear();