comparison src/edit.c @ 4448:ba53304245f0 v7.3.972

updated for version 7.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.
author Bram Moolenaar <bram@vim.org>
date Sun, 19 May 2013 21:15:15 +0200
parents 04736b4030ec
children 66803af09906
comparison
equal deleted inserted replaced
4447:7a054755d38d 4448:ba53304245f0
380 else if (cmdchar == 'V') 380 else if (cmdchar == 'V')
381 ptr = (char_u *)"v"; 381 ptr = (char_u *)"v";
382 else 382 else
383 ptr = (char_u *)"i"; 383 ptr = (char_u *)"i";
384 set_vim_var_string(VV_INSERTMODE, ptr, 1); 384 set_vim_var_string(VV_INSERTMODE, ptr, 1);
385 set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */
385 # endif 386 # endif
386 apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf); 387 apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf);
387 388
388 /* Since Insert mode was not started yet a call to check_cursor_col() 389 /* Make sure the cursor didn't move. Do call check_cursor_col() in
389 * may have moved the cursor, especially with the "A" command. */ 390 * case the text was modified. Since Insert mode was not started yet
390 if (curwin->w_cursor.col != save_cursor.col 391 * a call to check_cursor_col() may move the cursor, especially with
391 && curwin->w_cursor.lnum == save_cursor.lnum) 392 * the "A" command, thus set State to avoid that. Also check that the
393 * line number is still valid (lines may have been deleted).
394 * Do not restore if v:char was set to a non-empty string. */
395 if (!equalpos(curwin->w_cursor, save_cursor)
396 # ifdef FEAT_EVAL
397 && *get_vim_var_str(VV_CHAR) == NUL
398 # endif
399 && save_cursor.lnum <= curbuf->b_ml.ml_line_count)
392 { 400 {
393 int save_state = State; 401 int save_state = State;
394 402
395 curwin->w_cursor = save_cursor; 403 curwin->w_cursor = save_cursor;
396 State = INSERT; 404 State = INSERT;