@@ -9,7 +9,7 @@ use std::borrow::Cow;
99
1010use crossterm::{
1111 cursor,
12− event::{read, Event, EventStream, KeyCode, KeyEvent},
12+ event::{read, Event, EventStream, KeyCode, KeyEvent, KeyModifiers},
1313};
1414use tui::{
1515 backend::CrosstermBackend,
@@ -333,10 +333,27 @@ impl Component for EditorView {
333333 }
334334 }
335335 mode => {
336− if let Some(command) = self.keymap[&mode].get(&keys) {
337− command(&mut cxt);
338−
339− // TODO: simplistic ensure cursor in view for now
336+ match keys.as_slice() {
337+ &[KeyEvent {
338+ code: KeyCode::Char(i @ '0'..='9'),
339+ modifiers: KeyModifiers::NONE,
340+ }] => {
341+ let i = i.to_digit(10).unwrap() as usize;
342+ cxt.editor.count = Some(cxt.editor.count.map_or(i, |c| c * 10 + i));
343+ }
344+ _ => {
345+ // set the count
346+ cxt.count = cxt.editor.count.take().unwrap_or(1);
347+ // TODO: edge case: 0j -> reset to 1
348+ // if this fails, count was Some(0)
349+ // debug_assert!(cxt.count != 0);
350+
351+ if let Some(command) = self.keymap[&mode].get(&keys) {
352+ command(&mut cxt);
353+
354+ // TODO: simplistic ensure cursor in view for now
355+ }
356+ }
340357 }
341358 }
342359 }