From 0e08f7de0ff69c5b4c7bae34f29c79b16486ac99 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 3 Oct 2010 04:41:51 +0200 Subject: vim_mode: Fix undo if some changes were already undid. --- vim-mode/vim_mode.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 512a281..74d8403 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -1872,6 +1872,14 @@ sub UNLOAD { sub _add_undo_entry { my ($line, $pos) = @_; + + # If we aren't at the top of the history stack, then drop newer entries as + # we can't branch (yet). + while ($undo_index > 0) { + shift @undo_buffer; + $undo_index--; + } + # check it's not a dupe of the list head my $current = $undo_buffer[$undo_index]; if ($line eq $current->[0] && $pos == $current->[1]) { -- cgit v1.2.3