From 8949a4d0a231efd366fa272fad12c0ec9de882b2 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 3 Oct 2010 03:27:18 +0200 Subject: vim_mode: Hopefully fix undo positions. --- vim-mode/vim_mode.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index a0afc6c..0e665e6 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -1671,6 +1671,16 @@ sub handle_command_cmd { my $cur_pos = _input_pos(); + # Update input position of last undo entry so that undo/redo + # restores correct position. + if (@undo_buffer and _input() eq $undo_buffer[0]->[0] and + (defined $operator or exists $movements_repeatable->{$char} or + $char eq '.')) { + print "Updating history position: $undo_buffer[0]->[0]" + if DEBUG; + $undo_buffer[0]->[1] = $cur_pos; + } + # If defined $cur_pos will be changed to this. my $old_pos; # Position after the move. @@ -1725,7 +1735,7 @@ sub handle_command_cmd { # TODO: why do histpry entries still show up in undo # buffer? Is avoiding the commands here insufficient? - _add_undo_entry(_input(), $cur_pos); + _add_undo_entry(_input(), _input_pos()); } # Store command, necessary for . -- cgit v1.2.3