aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Ruderich <simon@ruderich.org>2010-09-26 22:34:56 +0000
committerSimon Ruderich <simon@ruderich.org>2010-09-26 22:34:56 +0000
commit375b559ea9f085bd0a2586a5e9f71b41438755b2 (patch)
treef4ee3f66ed5aebb0d1468afffb96e7c4e328b39d
parentvim_mode: Fix my nick. (diff)
downloadirssi-scripts-375b559ea9f085bd0a2586a5e9f71b41438755b2.tar.gz
irssi-scripts-375b559ea9f085bd0a2586a5e9f71b41438755b2.zip
vim_mode: Correctly handle multiple whitespace between words.
Thanks to SvenG for reporting this bug.
-rw-r--r--vim-mode/vim_mode.pl21
1 files changed, 10 insertions, 11 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl
index be71e75..d1dde46 100644
--- a/vim-mode/vim_mode.pl
+++ b/vim-mode/vim_mode.pl
@@ -410,12 +410,11 @@ sub cmd_movement_W {
my ($count, $pos) = @_;
my $input = _input();
- while ($count-- > 0) {
- $pos = index $input, ' ', $pos + 1;
- if ($pos == -1) {
+ while ($count-- > 0 and length($input) > $pos) {
+ if (substr($input, $pos + 1) !~ /\s+/) {
return cmd_movement_dollar();
}
- $pos++;
+ $pos += $+[0] + 1;
}
_input_pos($pos);
}
@@ -444,19 +443,19 @@ sub cmd_movement_E {
sub _end_of_WORD {
my ($input, $count, $pos) = @_;
- # We are already at the end of one a word, ignore the following space so
- # we can skip over it.
- if (index $input, ' ', $pos + 1 == $pos + 1) {
- $pos++;
+ # We are inside a word, skip to the end of it.
+ if (substr($input, $pos + 1) =~ /^\S+(\s)/) {
+ $pos += $-[1];
+ $count--;
}
while ($count-- > 0) {
- $pos = index $input, ' ', $pos + 1;
- if ($pos == -1) {
+ if (substr($input, $pos) !~ /\s+\S+(\s+)/) {
return -1;
}
+ $pos += $-[1] - 1;
}
- return $pos - 1;
+ return $pos;
}
sub cmd_movement_0 {