Karsten Hopp 99db9a
To: vim_dev@googlegroups.com
Karsten Hopp 99db9a
Subject: Patch 7.3.768
Karsten Hopp 99db9a
Fcc: outbox
Karsten Hopp 99db9a
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 99db9a
Mime-Version: 1.0
Karsten Hopp 99db9a
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 99db9a
Content-Transfer-Encoding: 8bit
Karsten Hopp 99db9a
------------
Karsten Hopp 99db9a
Karsten Hopp 99db9a
Patch 7.3.768
Karsten Hopp 99db9a
Problem:    settabvar() and setwinvar() may move the cursor.
Karsten Hopp 99db9a
Solution:   Save and restore the cursor position when appropriate. (idea by
Karsten Hopp 99db9a
	    Yasuhiro Matsumoto)
Karsten Hopp 99db9a
Files:	    src/edit.c
Karsten Hopp 99db9a
Karsten Hopp 99db9a
Karsten Hopp 99db9a
*** ../vim-7.3.767/src/edit.c	2012-10-21 00:10:29.000000000 +0200
Karsten Hopp 99db9a
--- src/edit.c	2013-01-17 15:32:10.000000000 +0100
Karsten Hopp 99db9a
***************
Karsten Hopp 99db9a
*** 372,377 ****
Karsten Hopp 99db9a
--- 372,379 ----
Karsten Hopp 99db9a
       */
Karsten Hopp 99db9a
      if (cmdchar != 'r' && cmdchar != 'v')
Karsten Hopp 99db9a
      {
Karsten Hopp 99db9a
+ 	pos_T   save_cursor = curwin->w_cursor;
Karsten Hopp 99db9a
+ 
Karsten Hopp 99db9a
  # ifdef FEAT_EVAL
Karsten Hopp 99db9a
  	if (cmdchar == 'R')
Karsten Hopp 99db9a
  	    ptr = (char_u *)"r";
Karsten Hopp 99db9a
***************
Karsten Hopp 99db9a
*** 382,387 ****
Karsten Hopp 99db9a
--- 384,402 ----
Karsten Hopp 99db9a
  	set_vim_var_string(VV_INSERTMODE, ptr, 1);
Karsten Hopp 99db9a
  # endif
Karsten Hopp 99db9a
  	apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf);
Karsten Hopp 99db9a
+ 
Karsten Hopp 99db9a
+ 	/* Since Insert mode was not started yet a call to check_cursor_col()
Karsten Hopp 99db9a
+ 	 * may have moved the cursor, especially with the "A" command. */
Karsten Hopp 99db9a
+ 	if (curwin->w_cursor.col != save_cursor.col
Karsten Hopp 99db9a
+ 		&& curwin->w_cursor.lnum == save_cursor.lnum)
Karsten Hopp 99db9a
+ 	{
Karsten Hopp 99db9a
+ 	    int save_state = State;
Karsten Hopp 99db9a
+ 
Karsten Hopp 99db9a
+ 	    curwin->w_cursor = save_cursor;
Karsten Hopp 99db9a
+ 	    State = INSERT;
Karsten Hopp 99db9a
+ 	    check_cursor_col();
Karsten Hopp 99db9a
+ 	    State = save_state;
Karsten Hopp 99db9a
+ 	}
Karsten Hopp 99db9a
      }
Karsten Hopp 99db9a
  #endif
Karsten Hopp 99db9a
  
Karsten Hopp 99db9a
*** ../vim-7.3.767/src/version.c	2013-01-17 14:39:43.000000000 +0100
Karsten Hopp 99db9a
--- src/version.c	2013-01-17 15:10:48.000000000 +0100
Karsten Hopp 99db9a
***************
Karsten Hopp 99db9a
*** 727,728 ****
Karsten Hopp 99db9a
--- 727,730 ----
Karsten Hopp 99db9a
  {   /* Add new patch number below this line */
Karsten Hopp 99db9a
+ /**/
Karsten Hopp 99db9a
+     768,
Karsten Hopp 99db9a
  /**/
Karsten Hopp 99db9a
Karsten Hopp 99db9a
-- 
Karsten Hopp 99db9a
Life would be so much easier if we could just look at the source code.
Karsten Hopp 99db9a
Karsten Hopp 99db9a
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 99db9a
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 99db9a
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 99db9a
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///