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