diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-05-19 21:15:15 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-05-19 21:15:15 +0200 |
commit | 097c992c464b0fbf04c3b3464a3ac512725ae0ba (patch) | |
tree | 690102448794b4f4867d6735d1db450853897410 /src/edit.c | |
parent | 884f6e44e03b2a599cd70b12360b7c7e42242e00 (diff) |
updated for version 7.3.972v7.3.972
Problem: Cursor not restored after InsertEnter autocommand if it moved to
another line.
Solution: Also restore if the saved line number is still valid. Allow
setting v:char to skip restoring.
Diffstat (limited to 'src/edit.c')
-rw-r--r-- | src/edit.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/edit.c b/src/edit.c index 6c21010156..c9a271d66c 100644 --- a/src/edit.c +++ b/src/edit.c @@ -382,13 +382,21 @@ edit(cmdchar, startln, count) else ptr = (char_u *)"i"; set_vim_var_string(VV_INSERTMODE, ptr, 1); + set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */ # 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) + /* Make sure the cursor didn't move. Do call check_cursor_col() in + * case the text was modified. Since Insert mode was not started yet + * a call to check_cursor_col() may move the cursor, especially with + * the "A" command, thus set State to avoid that. Also check that the + * line number is still valid (lines may have been deleted). + * Do not restore if v:char was set to a non-empty string. */ + if (!equalpos(curwin->w_cursor, save_cursor) +# ifdef FEAT_EVAL + && *get_vim_var_str(VV_CHAR) == NUL +# endif + && save_cursor.lnum <= curbuf->b_ml.ml_line_count) { int save_state = State; |