aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Ruderich <simon@ruderich.org>2010-09-29 01:47:08 +0000
committerSimon Ruderich <simon@ruderich.org>2010-09-29 13:59:15 +0000
commit5cbd1e07ee5a7d75019512150d34db98788056e7 (patch)
treebfae6b55e8a98cfe9c2e763f0410080ddc21ff8d
parentadditional debug prints in _input(_pos) to determine why undo positions are (diff)
downloadirssi-scripts-5cbd1e07ee5a7d75019512150d34db98788056e7.tar.gz
irssi-scripts-5cbd1e07ee5a7d75019512150d34db98788056e7.zip
vim_mode: Fix cursor position to work like Vim.
-rw-r--r--vim-mode/vim_mode.pl11
1 files changed, 11 insertions, 0 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl
index 8dfa35d..786921c 100644
--- a/vim-mode/vim_mode.pl
+++ b/vim-mode/vim_mode.pl
@@ -1370,6 +1370,17 @@ sub _stop() {
sub _update_mode {
my ($new_mode) = @_;
+
+ # In insert mode we are "between" characters, in command mode "on top" of
+ # keys. When leaving insert mode we have to move on key left to accomplish
+ # that.
+ if ($mode == M_INS and $new_mode == M_CMD) {
+ my $pos = _input_pos();
+ if ($pos != 0) {
+ _input_pos($pos - 1);
+ }
+ }
+
$mode = $new_mode;
if ($mode == M_INS) {
$history_index = undef;