]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.972 v7.3.972
authorBram Moolenaar <Bram@vim.org>
Sun, 19 May 2013 19:15:15 +0000 (21:15 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 19 May 2013 19:15:15 +0000 (21:15 +0200)
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.

runtime/doc/autocmd.txt
src/edit.c
src/version.c

index d9f40f49b1af1ccc617966276e77b14e699a1f69..364670a94ad4be25b4f58881644aa22c831920f3 100644 (file)
@@ -691,8 +691,11 @@ InsertCharPre                      When a character is typed in Insert mode,
 InsertEnter                    Just before starting Insert mode.  Also for
                                Replace mode and Virtual Replace mode.  The
                                |v:insertmode| variable indicates the mode.
-                               Be careful not to move the cursor or do
-                               anything else that the user does not expect.
+                               Be careful not to do anything else that the
+                               user does not expect.
+                               The cursor is restored afterwards.  If you do
+                               not want that set |v:char| to a non-empty
+                               string.
                                                        *InsertLeave*
 InsertLeave                    When leaving Insert mode.  Also when using
                                CTRL-O |i_CTRL-O|.  But not for |i_CTRL-C|.
index 6c210101563bfeb7cb3f86480f9fa4ffef0fb0ee..c9a271d66cc020fdaeda1dc23cb0428206df511f 100644 (file)
@@ -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;
 
index 6604a694f972ea77d196a5aaac281017a79555f8..7cb69987c2e624099d76b9b87aeaa9f8148fbe06 100644 (file)
@@ -728,6 +728,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    972,
 /**/
     971,
 /**/