diff --git a/src/keymap.rs b/src/keymap.rs index 3bb0ae9bb3e248a253a5a5028958995190dd6ba9..20a3b6d3f8b304744cc8b36a14387e4b3debec12 100644 --- a/src/keymap.rs +++ b/src/keymap.rs @@ -132,7 +132,13 @@ impl EditState { match key { KeyPress::Char(digit @ '0'...'9') | KeyPress::Meta(digit @ '0'...'9') => { - self.num_args = self.num_args * 10 + digit.to_digit(10).unwrap() as i16; + if self.num_args == -1 { + self.num_args = self.num_args * digit.to_digit(10).unwrap() as i16; + } else { + self.num_args = self.num_args + .saturating_mul(10) + .saturating_add(digit.to_digit(10).unwrap() as i16); + } } _ => return Ok(key), }; @@ -238,7 +244,9 @@ impl EditState { let key = try!(rdr.next_key(config.keyseq_timeout())); match key { KeyPress::Char(digit @ '0'...'9') => { - self.num_args = self.num_args * 10 + digit.to_digit(10).unwrap() as i16; + self.num_args = self.num_args + .saturating_mul(10) + .saturating_add(digit.to_digit(10).unwrap() as i16); } _ => return Ok(key), }; diff --git a/src/lib.rs b/src/lib.rs index eef4b9da064b32e46e37c11324b74065f2f580a8..986f1be899ea9c8e64ae508d149e82747950af51 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -482,7 +482,11 @@ fn edit_move_to(s: &mut State, cs: CharSearch, n: RepeatCount) -> Result<()> { } /// Kill from the cursor to the end of the current word, or, if between words, to the end of the next word. -fn edit_delete_word(s: &mut State, at: At, word_def: Word, n: RepeatCount) -> Result<Option<String>> { +fn edit_delete_word(s: &mut State, + at: At, + word_def: Word, + n: RepeatCount) + -> Result<Option<String>> { if let Some(text) = s.line.delete_word(at, word_def, n) { try!(s.refresh_line()); Ok(Some(text)) diff --git a/src/line_buffer.rs b/src/line_buffer.rs index b114036bbcfd35809e5f2d6c670208e920c7d954..f621994cb4ac2512fa9afbebaa25d21260084322 100644 --- a/src/line_buffer.rs +++ b/src/line_buffer.rs @@ -391,7 +391,11 @@ impl LineBuffer { /// Go right until end of word /// Returns the position (start, end) of the next word. - fn next_end_of_word_pos(&self, pos: usize, word_def: Word, n: RepeatCount) -> Option<(usize, usize)> { + fn next_end_of_word_pos(&self, + pos: usize, + word_def: Word, + n: RepeatCount) + -> Option<(usize, usize)> { if pos == self.buf.len() { return None; }