From 8f0bcfe286d97dfff67bd924e11ca2b6ae1a63dc Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 30 Oct 2020 14:09:59 +0900 Subject: Introduce a command context that carries the executor and other fields. --- helix-term/src/application.rs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index a4a3cf09..cacfde56 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -476,13 +476,24 @@ impl<'a> Application<'a> { match view.doc.mode() { Mode::Insert => { if let Some(command) = self.keymap[&Mode::Insert].get(&keys) { - command(view, 1); + let mut cx = helix_view::commands::Context { + view, + executor: self.executor, + count: 1, + }; + + command(&mut cx); } else if let KeyEvent { code: KeyCode::Char(c), .. } = event { - commands::insert::insert_char(view, c); + let mut cx = helix_view::commands::Context { + view, + executor: self.executor, + count: 1, + }; + commands::insert::insert_char(&mut cx, c); } view.ensure_cursor_in_view(); } @@ -544,7 +555,12 @@ impl<'a> Application<'a> { // HAXX: special casing for command mode } else if let Some(command) = self.keymap[&Mode::Normal].get(&keys) { - command(view, 1); + let mut cx = helix_view::commands::Context { + view, + executor: self.executor, + count: 1, + }; + command(&mut cx); // TODO: simplistic ensure cursor in view for now view.ensure_cursor_in_view(); @@ -552,7 +568,12 @@ impl<'a> Application<'a> { } mode => { if let Some(command) = self.keymap[&mode].get(&keys) { - command(view, 1); + let mut cx = helix_view::commands::Context { + view, + executor: self.executor, + count: 1, + }; + command(&mut cx); // TODO: simplistic ensure cursor in view for now view.ensure_cursor_in_view(); -- cgit v1.2.3-70-g09d2