diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-01-17 15:37:01 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-01-17 15:37:01 +0100 |
commit | 3e37fd0950081e277fac44a0bd8e60815898945c (patch) | |
tree | bb46b1cc1bb67e971b33d6b57fdcfb771da92e89 | |
parent | 8fae8e658ffd8f5177a22e41ece18ea32edaa4a2 (diff) | |
download | vim-git-3e37fd0950081e277fac44a0bd8e60815898945c.tar.gz |
updated for version 7.3.768v7.3.768
Problem: settabvar() and setwinvar() may move the cursor.
Solution: Save and restore the cursor position when appropriate. (idea by
Yasuhiro Matsumoto)
-rw-r--r-- | src/edit.c | 15 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/edit.c b/src/edit.c index 0d9409546..50c1fca6b 100644 --- a/src/edit.c +++ b/src/edit.c @@ -372,6 +372,8 @@ edit(cmdchar, startln, count) */ if (cmdchar != 'r' && cmdchar != 'v') { + pos_T save_cursor = curwin->w_cursor; + # ifdef FEAT_EVAL if (cmdchar == 'R') ptr = (char_u *)"r"; @@ -382,6 +384,19 @@ edit(cmdchar, startln, count) set_vim_var_string(VV_INSERTMODE, ptr, 1); # endif apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf); + + /* Since Insert mode was not started yet a call to check_cursor_col() + * may have moved the cursor, especially with the "A" command. */ + if (curwin->w_cursor.col != save_cursor.col + && curwin->w_cursor.lnum == save_cursor.lnum) + { + int save_state = State; + + curwin->w_cursor = save_cursor; + State = INSERT; + check_cursor_col(); + State = save_state; + } } #endif diff --git a/src/version.c b/src/version.c index 321740010..251cec813 100644 --- a/src/version.c +++ b/src/version.c @@ -726,6 +726,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 768, +/**/ 767, /**/ 766, |