From 30e704c5305844bd789e6a36d5103b379e96cc18 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Thu, 7 Oct 2010 22:00:01 +0200 Subject: vim_mode: Fix yank movement and behavior. Reported by estragib. --- vim-mode/vim_mode.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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) = @_; -- cgit v1.2.3