diff options
author | Simon Ruderich <simon@ruderich.org> | 2010-10-07 20:00:01 +0000 |
---|---|---|
committer | Simon Ruderich <simon@ruderich.org> | 2010-10-07 20:00:01 +0000 |
commit | 30e704c5305844bd789e6a36d5103b379e96cc18 (patch) | |
tree | cf32f66c97948c86f5eb9ed806b62146e8c0c29d | |
parent | vim_mode: Minor documentation updates. (diff) | |
download | irssi-scripts-30e704c5305844bd789e6a36d5103b379e96cc18.tar.gz irssi-scripts-30e704c5305844bd789e6a36d5103b379e96cc18.zip |
vim_mode: Fix yank movement and behavior.
Reported by estragib.
Diffstat (limited to '')
-rw-r--r-- | vim-mode/vim_mode.pl | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index ea43169..ce9dc2a 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -510,6 +510,12 @@ sub cmd_operator_y { my ($pos, $length) = _get_pos_and_length($old_pos, $new_pos, $move); + # When yanking left of the current char, the current char is not included + # in the yank. + if ($old_pos > $new_pos) { + $length--; + } + # Extract the selected string and put it in the " register. my $input = _input(); my $string = substr $input, $pos, $length; @@ -521,7 +527,12 @@ sub cmd_operator_y { print "Yanked into $register: ", $registers->{$register} if DEBUG; } - _input_pos($old_pos); + # Always move to the lower position. + if ($old_pos > $new_pos) { + _input_pos($new_pos); + } else { + _input_pos($old_pos); + } } sub _get_pos_and_length { my ($old_pos, $new_pos, $move) = @_; |