diff options
| author | Simon Ruderich <simon@ruderich.org> | 2010-10-03 00:50:36 +0000 | 
|---|---|---|
| committer | Simon Ruderich <simon@ruderich.org> | 2010-10-03 00:50:36 +0000 | 
| commit | 26d93fa047f6d3f55e287268f52b415e050fe819 (patch) | |
| tree | 3545e79e5e1feadf434e0d997f52b5d5c6d8fbcf | |
| parent | vim_mode: Only undo operators, repeatable movements and repetitions. (diff) | |
| download | irssi-scripts-26d93fa047f6d3f55e287268f52b415e050fe819.tar.gz irssi-scripts-26d93fa047f6d3f55e287268f52b415e050fe819.zip | |
vim_mode: Hopefully fix undo/redo.
| -rw-r--r-- | vim-mode/vim_mode.pl | 34 | 
1 files changed, 19 insertions, 15 deletions
| diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 3982c93..a0afc6c 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -1192,10 +1192,11 @@ sub cmd_movement_g {  sub cmd_undo {      print "Undo!" if DEBUG; -    _restore_undo_entry($undo_index); -    print "Undoing entry index: $undo_index of " . scalar(@undo_buffer) if DEBUG;      if ($undo_index != $#undo_buffer) {          $undo_index++; +        _restore_undo_entry($undo_index); +        print "Undoing entry index: $undo_index of " . scalar(@undo_buffer) +            if DEBUG;      } else {          print "No further undo." if DEBUG;      } @@ -1203,12 +1204,12 @@ sub cmd_undo {  }  sub cmd_redo {      print "Redo!" if DEBUG; -    print "Undoing entry index: $undo_index of " . scalar(@undo_buffer) if DEBUG; - -    _restore_undo_entry($undo_index);      if ($undo_index != 0) {          $undo_index--; +        print "Undoing entry index: $undo_index of " . scalar(@undo_buffer) +            if DEBUG; +        _restore_undo_entry($undo_index);      } else {          print "No further Redo." if DEBUG;      } @@ -1670,16 +1671,6 @@ sub handle_command_cmd {              my $cur_pos = _input_pos(); -            # Save an undo checkpoint here for operators, all repeatable -            # movements, operators and repetition. -            if (defined $operator or exists $movements_repeatable->{$char} or -                                     $char eq '.') { -                # TODO: why do histpry entries still show up in undo -                # buffer? Is avoiding the commands here insufficient? - -                _add_undo_entry(_input(), $cur_pos); -            } -              # If defined $cur_pos will be changed to this.              my $old_pos;              # Position after the move. @@ -1727,6 +1718,16 @@ sub handle_command_cmd {                                                    $tmp_char, $repeat);              } +            # Save an undo checkpoint here for operators, all repeatable +            # movements, operators and repetition. +            if (defined $operator or exists $movements_repeatable->{$char} or +                                     $char eq '.') { +                # TODO: why do histpry entries still show up in undo +                # buffer? Is avoiding the commands here insufficient? + +                _add_undo_entry(_input(), $cur_pos); +            } +              # Store command, necessary for .              if ($operator or exists $movements_repeatable->{$char}) {                  $last->{char} = $char; @@ -2005,6 +2006,9 @@ sub _update_mode {                  _input_pos($pos - 1);              }          } +        # Store current line to allow undo of i/a/I/A. +        _add_undo_entry(_input(), _input_pos()); +      # Change mode to i to support insert mode repetition. This doesn't affect      # commands like i/a/I/A because handle_command_cmd() sets $last->{char}.      # It's necessary when pressing enter. | 
