Commits

Bram Moolenaar  committed 9ea81cd

updated for version 7.3.768
Problem: settabvar() and setwinvar() may move the cursor.
Solution: Save and restore the cursor position when appropriate. (idea by
Yasuhiro Matsumoto)

  • Participants
  • Parent commits d7b049b
  • Tags v7-3-768

Comments (0)

Files changed (2)

      */
     if (cmdchar != 'r' && cmdchar != 'v')
     {
+	pos_T   save_cursor = curwin->w_cursor;
+
 # ifdef FEAT_EVAL
 	if (cmdchar == 'R')
 	    ptr = (char_u *)"r";
 	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
 

File src/version.c

 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    768,
+/**/
     767,
 /**/
     766,