Karsten Hopp 7d1ef0
To: vim_dev@googlegroups.com
Karsten Hopp 7d1ef0
Subject: Patch 7.3.972
Karsten Hopp 7d1ef0
Fcc: outbox
Karsten Hopp 7d1ef0
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 7d1ef0
Mime-Version: 1.0
Karsten Hopp 7d1ef0
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 7d1ef0
Content-Transfer-Encoding: 8bit
Karsten Hopp 7d1ef0
------------
Karsten Hopp 7d1ef0
Karsten Hopp 7d1ef0
Patch 7.3.972
Karsten Hopp 7d1ef0
Problem:    Cursor not restored after InsertEnter autocommand if it moved to
Karsten Hopp 7d1ef0
	    another line.
Karsten Hopp 7d1ef0
Solution:   Also restore if the saved line number is still valid.  Allow
Karsten Hopp 7d1ef0
	    setting v:char to skip restoring.
Karsten Hopp 7d1ef0
Files:	    src/edit.c, runtime/doc/autocmd.txt
Karsten Hopp 7d1ef0
Karsten Hopp 7d1ef0
Karsten Hopp 7d1ef0
*** ../vim-7.3.971/src/edit.c	2013-05-06 04:21:35.000000000 +0200
Karsten Hopp 7d1ef0
--- src/edit.c	2013-05-19 21:09:37.000000000 +0200
Karsten Hopp 7d1ef0
***************
Karsten Hopp 7d1ef0
*** 382,394 ****
Karsten Hopp 7d1ef0
  	else
Karsten Hopp 7d1ef0
  	    ptr = (char_u *)"i";
Karsten Hopp 7d1ef0
  	set_vim_var_string(VV_INSERTMODE, ptr, 1);
Karsten Hopp 7d1ef0
  # endif
Karsten Hopp 7d1ef0
  	apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf);
Karsten Hopp 7d1ef0
  
Karsten Hopp 7d1ef0
! 	/* Since Insert mode was not started yet a call to check_cursor_col()
Karsten Hopp 7d1ef0
! 	 * may have moved the cursor, especially with the "A" command. */
Karsten Hopp 7d1ef0
! 	if (curwin->w_cursor.col != save_cursor.col
Karsten Hopp 7d1ef0
! 		&& curwin->w_cursor.lnum == save_cursor.lnum)
Karsten Hopp 7d1ef0
  	{
Karsten Hopp 7d1ef0
  	    int save_state = State;
Karsten Hopp 7d1ef0
  
Karsten Hopp 7d1ef0
--- 382,402 ----
Karsten Hopp 7d1ef0
  	else
Karsten Hopp 7d1ef0
  	    ptr = (char_u *)"i";
Karsten Hopp 7d1ef0
  	set_vim_var_string(VV_INSERTMODE, ptr, 1);
Karsten Hopp 7d1ef0
+ 	set_vim_var_string(VV_CHAR, NULL, -1);  /* clear v:char */
Karsten Hopp 7d1ef0
  # endif
Karsten Hopp 7d1ef0
  	apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf);
Karsten Hopp 7d1ef0
  
Karsten Hopp 7d1ef0
! 	/* Make sure the cursor didn't move.  Do call check_cursor_col() in
Karsten Hopp 7d1ef0
! 	 * case the text was modified.  Since Insert mode was not started yet
Karsten Hopp 7d1ef0
! 	 * a call to check_cursor_col() may move the cursor, especially with
Karsten Hopp 7d1ef0
! 	 * the "A" command, thus set State to avoid that. Also check that the
Karsten Hopp 7d1ef0
! 	 * line number is still valid (lines may have been deleted).
Karsten Hopp 7d1ef0
! 	 * Do not restore if v:char was set to a non-empty string. */
Karsten Hopp 7d1ef0
! 	if (!equalpos(curwin->w_cursor, save_cursor)
Karsten Hopp 7d1ef0
! # ifdef FEAT_EVAL
Karsten Hopp 7d1ef0
! 		&& *get_vim_var_str(VV_CHAR) == NUL
Karsten Hopp 7d1ef0
! # endif
Karsten Hopp 7d1ef0
! 		&& save_cursor.lnum <= curbuf->b_ml.ml_line_count)
Karsten Hopp 7d1ef0
  	{
Karsten Hopp 7d1ef0
  	    int save_state = State;
Karsten Hopp 7d1ef0
  
Karsten Hopp 7d1ef0
*** ../vim-7.3.971/runtime/doc/autocmd.txt	2013-03-19 13:33:18.000000000 +0100
Karsten Hopp 7d1ef0
--- runtime/doc/autocmd.txt	2013-05-19 21:05:59.000000000 +0200
Karsten Hopp 7d1ef0
***************
Karsten Hopp 7d1ef0
*** 674,681 ****
Karsten Hopp 7d1ef0
  InsertEnter			Just before starting Insert mode.  Also for
Karsten Hopp 7d1ef0
  				Replace mode and Virtual Replace mode.  The
Karsten Hopp 7d1ef0
  				|v:insertmode| variable indicates the mode.
Karsten Hopp 7d1ef0
! 				Be careful not to move the cursor or do
Karsten Hopp 7d1ef0
! 				anything else that the user does not expect.
Karsten Hopp 7d1ef0
  							*InsertLeave*
Karsten Hopp 7d1ef0
  InsertLeave			When leaving Insert mode.  Also when using
Karsten Hopp 7d1ef0
  				CTRL-O |i_CTRL-O|.  But not for |i_CTRL-C|.
Karsten Hopp 7d1ef0
--- 691,701 ----
Karsten Hopp 7d1ef0
  InsertEnter			Just before starting Insert mode.  Also for
Karsten Hopp 7d1ef0
  				Replace mode and Virtual Replace mode.  The
Karsten Hopp 7d1ef0
  				|v:insertmode| variable indicates the mode.
Karsten Hopp 7d1ef0
! 				Be careful not to do anything else that the
Karsten Hopp 7d1ef0
! 				user does not expect.
Karsten Hopp 7d1ef0
! 				The cursor is restored afterwards.  If you do
Karsten Hopp 7d1ef0
! 				not want that set |v:char| to a non-empty
Karsten Hopp 7d1ef0
! 				string.
Karsten Hopp 7d1ef0
  							*InsertLeave*
Karsten Hopp 7d1ef0
  InsertLeave			When leaving Insert mode.  Also when using
Karsten Hopp 7d1ef0
  				CTRL-O |i_CTRL-O|.  But not for |i_CTRL-C|.
Karsten Hopp 7d1ef0
*** ../vim-7.3.971/src/version.c	2013-05-19 21:03:50.000000000 +0200
Karsten Hopp 7d1ef0
--- src/version.c	2013-05-19 21:13:10.000000000 +0200
Karsten Hopp 7d1ef0
***************
Karsten Hopp 7d1ef0
*** 730,731 ****
Karsten Hopp 7d1ef0
--- 730,733 ----
Karsten Hopp 7d1ef0
  {   /* Add new patch number below this line */
Karsten Hopp 7d1ef0
+ /**/
Karsten Hopp 7d1ef0
+     972,
Karsten Hopp 7d1ef0
  /**/
Karsten Hopp 7d1ef0
Karsten Hopp 7d1ef0
-- 
Karsten Hopp 7d1ef0
It is illegal for anyone to try and stop a child from playfully jumping over
Karsten Hopp 7d1ef0
puddles of water.
Karsten Hopp 7d1ef0
		[real standing law in California, United States of America]
Karsten Hopp 7d1ef0
Karsten Hopp 7d1ef0
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 7d1ef0
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 7d1ef0
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 7d1ef0
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///