3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.186
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.186 (after 7.4.085)
3ef2ca
Problem:    Insert in Visual mode sometimes gives incorrect results.
3ef2ca
            (Dominique Pelle)
3ef2ca
Solution:   Remember the original insert start position. (Christian Brabandt,
3ef2ca
            Dominique Pelle)
3ef2ca
Files:      src/edit.c, src/globals.h, src/ops.c, src/structs.h
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.185/src/edit.c	2014-01-23 22:45:54.608127182 +0100
3ef2ca
--- src/edit.c	2014-02-22 22:43:52.820903112 +0100
3ef2ca
***************
3ef2ca
*** 264,269 ****
3ef2ca
--- 264,270 ----
3ef2ca
  
3ef2ca
  static colnr_T	Insstart_textlen;	/* length of line when insert started */
3ef2ca
  static colnr_T	Insstart_blank_vcol;	/* vcol for first inserted blank */
3ef2ca
+ static int	update_Insstart_orig = TRUE; /* set Insstart_orig to Insstart */
3ef2ca
  
3ef2ca
  static char_u	*last_insert = NULL;	/* the text of the previous insert,
3ef2ca
  					   K_SPECIAL and CSI are escaped */
3ef2ca
***************
3ef2ca
*** 340,345 ****
3ef2ca
--- 341,349 ----
3ef2ca
       * error message */
3ef2ca
      check_for_delay(TRUE);
3ef2ca
  
3ef2ca
+     /* set Insstart_orig to Insstart */
3ef2ca
+     update_Insstart_orig = TRUE;
3ef2ca
+ 
3ef2ca
  #ifdef HAVE_SANDBOX
3ef2ca
      /* Don't allow inserting in the sandbox. */
3ef2ca
      if (sandbox != 0)
3ef2ca
***************
3ef2ca
*** 631,636 ****
3ef2ca
--- 635,643 ----
3ef2ca
  	if (arrow_used)	    /* don't repeat insert when arrow key used */
3ef2ca
  	    count = 0;
3ef2ca
  
3ef2ca
+ 	if (update_Insstart_orig)
3ef2ca
+ 	    Insstart_orig = Insstart;
3ef2ca
+ 
3ef2ca
  	if (stop_insert_mode)
3ef2ca
  	{
3ef2ca
  	    /* ":stopinsert" used or 'insertmode' reset */
3ef2ca
***************
3ef2ca
*** 6923,6928 ****
3ef2ca
--- 6930,6936 ----
3ef2ca
      if (end_insert_pos != NULL)
3ef2ca
      {
3ef2ca
  	curbuf->b_op_start = Insstart;
3ef2ca
+ 	curbuf->b_op_start_orig = Insstart_orig;
3ef2ca
  	curbuf->b_op_end = *end_insert_pos;
3ef2ca
      }
3ef2ca
  }
3ef2ca
***************
3ef2ca
*** 8257,8262 ****
3ef2ca
--- 8265,8271 ----
3ef2ca
  
3ef2ca
  		  /* Need to reset Insstart, esp. because a BS that joins
3ef2ca
  		   * a line to the previous one must save for undo. */
3ef2ca
+ 		  update_Insstart_orig = FALSE;
3ef2ca
  		  Insstart = curwin->w_cursor;
3ef2ca
  		  break;
3ef2ca
  
3ef2ca
*** ../vim-7.4.185/src/globals.h	2014-02-11 15:10:38.130111835 +0100
3ef2ca
--- src/globals.h	2014-02-22 23:02:01.644901378 +0100
3ef2ca
***************
3ef2ca
*** 752,757 ****
3ef2ca
--- 752,763 ----
3ef2ca
   */
3ef2ca
  EXTERN pos_T	Insstart;		/* This is where the latest
3ef2ca
  					 * insert/append mode started. */
3ef2ca
+ 
3ef2ca
+ /* This is where the latest insert/append mode started. In contrast to
3ef2ca
+  * Insstart, this won't be reset by certain keys and is needed for
3ef2ca
+  * op_insert(), to detect correctly where inserting by the user started. */
3ef2ca
+ EXTERN pos_T	Insstart_orig;
3ef2ca
+ 
3ef2ca
  #ifdef FEAT_VREPLACE
3ef2ca
  /*
3ef2ca
   * Stuff for VREPLACE mode.
3ef2ca
*** ../vim-7.4.185/src/ops.c	2014-02-11 19:33:03.358353098 +0100
3ef2ca
--- src/ops.c	2014-02-22 22:39:47.588903502 +0100
3ef2ca
***************
3ef2ca
*** 2643,2662 ****
3ef2ca
  
3ef2ca
  	/* The user may have moved the cursor before inserting something, try
3ef2ca
  	 * to adjust the block for that. */
3ef2ca
! 	if (oap->start.lnum == curbuf->b_op_start.lnum && !bd.is_MAX)
3ef2ca
  	{
3ef2ca
  	    if (oap->op_type == OP_INSERT
3ef2ca
! 		    && oap->start.col != curbuf->b_op_start.col)
3ef2ca
  	    {
3ef2ca
! 		oap->start.col = curbuf->b_op_start.col;
3ef2ca
  		pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
3ef2ca
  							    - oap->start_vcol;
3ef2ca
  		oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
3ef2ca
  	    }
3ef2ca
  	    else if (oap->op_type == OP_APPEND
3ef2ca
! 		    && oap->end.col >= curbuf->b_op_start.col)
3ef2ca
  	    {
3ef2ca
! 		oap->start.col = curbuf->b_op_start.col;
3ef2ca
  		/* reset pre_textlen to the value of OP_INSERT */
3ef2ca
  		pre_textlen += bd.textlen;
3ef2ca
  		pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
3ef2ca
--- 2643,2662 ----
3ef2ca
  
3ef2ca
  	/* The user may have moved the cursor before inserting something, try
3ef2ca
  	 * to adjust the block for that. */
3ef2ca
! 	if (oap->start.lnum == curbuf->b_op_start_orig.lnum && !bd.is_MAX)
3ef2ca
  	{
3ef2ca
  	    if (oap->op_type == OP_INSERT
3ef2ca
! 		    && oap->start.col != curbuf->b_op_start_orig.col)
3ef2ca
  	    {
3ef2ca
! 		oap->start.col = curbuf->b_op_start_orig.col;
3ef2ca
  		pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
3ef2ca
  							    - oap->start_vcol;
3ef2ca
  		oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
3ef2ca
  	    }
3ef2ca
  	    else if (oap->op_type == OP_APPEND
3ef2ca
! 		    && oap->end.col >= curbuf->b_op_start_orig.col)
3ef2ca
  	    {
3ef2ca
! 		oap->start.col = curbuf->b_op_start_orig.col;
3ef2ca
  		/* reset pre_textlen to the value of OP_INSERT */
3ef2ca
  		pre_textlen += bd.textlen;
3ef2ca
  		pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
3ef2ca
*** ../vim-7.4.185/src/structs.h	2014-02-11 15:10:38.138111836 +0100
3ef2ca
--- src/structs.h	2014-02-22 22:39:47.588903502 +0100
3ef2ca
***************
3ef2ca
*** 1449,1454 ****
3ef2ca
--- 1449,1455 ----
3ef2ca
       * start and end of an operator, also used for '[ and ']
3ef2ca
       */
3ef2ca
      pos_T	b_op_start;
3ef2ca
+     pos_T	b_op_start_orig;  /* used for Insstart_orig */
3ef2ca
      pos_T	b_op_end;
3ef2ca
  
3ef2ca
  #ifdef FEAT_VIMINFO
3ef2ca
*** ../vim-7.4.185/src/version.c	2014-02-22 22:27:20.772904692 +0100
3ef2ca
--- src/version.c	2014-02-22 22:39:08.932903564 +0100
3ef2ca
***************
3ef2ca
*** 740,741 ****
3ef2ca
--- 740,743 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     186,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
Individualists unite!
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///