aboutsummaryrefslogtreecommitdiffstats
path: root/vim-mode/vim_mode.pl
diff options
context:
space:
mode:
authorSimon Ruderich <simon@ruderich.org>2010-10-03 02:41:51 +0000
committerSimon Ruderich <simon@ruderich.org>2010-10-03 02:41:51 +0000
commit0e08f7de0ff69c5b4c7bae34f29c79b16486ac99 (patch)
tree22ebe85dd133fb086d14d7855720e7adf73b8089 /vim-mode/vim_mode.pl
parentvim_mode: Only track input positions for d operator. (diff)
downloadirssi-scripts-0e08f7de0ff69c5b4c7bae34f29c79b16486ac99.tar.gz
irssi-scripts-0e08f7de0ff69c5b4c7bae34f29c79b16486ac99.zip
vim_mode: Fix undo if some changes were already undid.
Diffstat (limited to '')
-rw-r--r--vim-mode/vim_mode.pl8
1 files changed, 8 insertions, 0 deletions
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]) {