Handle starting and continuing the count separately (#9887)

pull/9894/head
Michael Davis 9 months ago committed by GitHub
parent b961acf746
commit 9282f1b8e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -916,13 +916,15 @@ impl EditorView {
fn command_mode(&mut self, mode: Mode, cxt: &mut commands::Context, event: KeyEvent) { fn command_mode(&mut self, mode: Mode, cxt: &mut commands::Context, event: KeyEvent) {
match (event, cxt.editor.count) { match (event, cxt.editor.count) {
// count handling // If the count is already started and the input is a number, always continue the count.
(key!(i @ '0'), Some(_)) | (key!(i @ '1'..='9'), _) (key!(i @ '0'..='9'), Some(count)) => {
if !self.keymaps.contains_key(mode, event) => let i = i.to_digit(10).unwrap() as usize;
{ cxt.editor.count = NonZeroUsize::new(count.get() * 10 + i);
}
// A non-zero digit will start the count if that number isn't used by a keymap.
(key!(i @ '1'..='9'), None) if !self.keymaps.contains_key(mode, event) => {
let i = i.to_digit(10).unwrap() as usize; let i = i.to_digit(10).unwrap() as usize;
cxt.editor.count = cxt.editor.count = NonZeroUsize::new(i);
std::num::NonZeroUsize::new(cxt.editor.count.map_or(i, |c| c.get() * 10 + i));
} }
// special handling for repeat operator // special handling for repeat operator
(key!('.'), _) if self.keymaps.pending().is_empty() => { (key!('.'), _) if self.keymaps.pending().is_empty() => {

Loading…
Cancel
Save