From 7ca688cc824072ee6ec8dfc1fc486270bc54db4b Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 27 Sep 2010 22:11:40 +0200 Subject: vim_mode: Fix e at end of the line and b at beginning of line with leading space. --- vim-mode/vim_mode.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index dfc9bb2..40088fe 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -450,7 +450,9 @@ sub cmd_movement_b { $pos = 0 if ($pos < 0); $pos = _end_of_word($input, $count, $pos); - _input_pos(length($input) - $pos - 1); + $pos = length($input) - $pos - 1; + $pos = 0 if ($pos < 0); + _input_pos($pos); } sub cmd_movement_e { my ($count, $pos) = @_; @@ -462,7 +464,7 @@ sub cmd_movement_e { sub _end_of_word { my ($input, $count, $pos) = @_; - while ($count-- > 0) { + while ($count-- > 0 and length($input) > $pos) { my $skipped = 0; # Skip over whitespace if in the middle of it or directly after the # current word/non-word. -- cgit v1.2.3