]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.186 v7.4.186
authorBram Moolenaar <Bram@vim.org>
Sat, 22 Feb 2014 22:03:55 +0000 (23:03 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 22 Feb 2014 22:03:55 +0000 (23:03 +0100)
Problem:    Insert in Visual mode sometimes gives incorrect results.
            (Dominique Pelle)
Solution:   Remember the original insert start position. (Christian Brabandt,
            Dominique Pelle)

src/edit.c
src/globals.h
src/ops.c
src/structs.h
src/version.c

index 29d8d3e65d0dcb0a00aae90a02df7c9242aeac27..57bd7761e1b78364db7e9402c47d787aa55965d4 100644 (file)
@@ -264,6 +264,7 @@ static char_u *do_insert_char_pre __ARGS((int c));
 
 static colnr_T Insstart_textlen;       /* length of line when insert started */
 static colnr_T Insstart_blank_vcol;    /* vcol for first inserted blank */
+static int     update_Insstart_orig = TRUE; /* set Insstart_orig to Insstart */
 
 static char_u  *last_insert = NULL;    /* the text of the previous insert,
                                           K_SPECIAL and CSI are escaped */
@@ -340,6 +341,9 @@ edit(cmdchar, startln, count)
      * error message */
     check_for_delay(TRUE);
 
+    /* set Insstart_orig to Insstart */
+    update_Insstart_orig = TRUE;
+
 #ifdef HAVE_SANDBOX
     /* Don't allow inserting in the sandbox. */
     if (sandbox != 0)
@@ -631,6 +635,9 @@ edit(cmdchar, startln, count)
        if (arrow_used)     /* don't repeat insert when arrow key used */
            count = 0;
 
+       if (update_Insstart_orig)
+           Insstart_orig = Insstart;
+
        if (stop_insert_mode)
        {
            /* ":stopinsert" used or 'insertmode' reset */
@@ -6923,6 +6930,7 @@ stop_insert(end_insert_pos, esc, nomove)
     if (end_insert_pos != NULL)
     {
        curbuf->b_op_start = Insstart;
+       curbuf->b_op_start_orig = Insstart_orig;
        curbuf->b_op_end = *end_insert_pos;
     }
 }
@@ -8257,6 +8265,7 @@ ins_ctrl_g()
 
                  /* Need to reset Insstart, esp. because a BS that joins
                   * a line to the previous one must save for undo. */
+                 update_Insstart_orig = FALSE;
                  Insstart = curwin->w_cursor;
                  break;
 
index f72915411bc5341e3d8a2dfb0f1e7bc9dd9e379b..fd4e70c7424db5273390b2996c149d7925689f1c 100644 (file)
@@ -752,6 +752,12 @@ EXTERN pos_T       saved_cursor            /* w_cursor before formatting text. */
  */
 EXTERN pos_T   Insstart;               /* This is where the latest
                                         * insert/append mode started. */
+
+/* This is where the latest insert/append mode started. In contrast to
+ * Insstart, this won't be reset by certain keys and is needed for
+ * op_insert(), to detect correctly where inserting by the user started. */
+EXTERN pos_T   Insstart_orig;
+
 #ifdef FEAT_VREPLACE
 /*
  * Stuff for VREPLACE mode.
index 8505f64a5b3e13de92fd7fe615d0468443453ab6..4517e4225fe04c0ea88d368607f48c3702bfe926 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -2643,20 +2643,20 @@ op_insert(oap, count1)
 
        /* The user may have moved the cursor before inserting something, try
         * to adjust the block for that. */
-       if (oap->start.lnum == curbuf->b_op_start.lnum && !bd.is_MAX)
+       if (oap->start.lnum == curbuf->b_op_start_orig.lnum && !bd.is_MAX)
        {
            if (oap->op_type == OP_INSERT
-                   && oap->start.col != curbuf->b_op_start.col)
+                   && oap->start.col != curbuf->b_op_start_orig.col)
            {
-               oap->start.col = curbuf->b_op_start.col;
+               oap->start.col = curbuf->b_op_start_orig.col;
                pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
                                                            - oap->start_vcol;
                oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
            }
            else if (oap->op_type == OP_APPEND
-                   && oap->end.col >= curbuf->b_op_start.col)
+                   && oap->end.col >= curbuf->b_op_start_orig.col)
            {
-               oap->start.col = curbuf->b_op_start.col;
+               oap->start.col = curbuf->b_op_start_orig.col;
                /* reset pre_textlen to the value of OP_INSERT */
                pre_textlen += bd.textlen;
                pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
index c3f0312c1a52a32e20aefa6f29b2a33d87f2b894..5de3a683e6202bc01d907ee0815ae388b08bd548 100644 (file)
@@ -1449,6 +1449,7 @@ struct file_buffer
      * start and end of an operator, also used for '[ and ']
      */
     pos_T      b_op_start;
+    pos_T      b_op_start_orig;  /* used for Insstart_orig */
     pos_T      b_op_end;
 
 #ifdef FEAT_VIMINFO
index 221df42388ad2fec4529a2c7e18f6e7687649d4b..8dcd656cac78023755bbee4fea5687f6f3eebf21 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    186,
 /**/
     185,
 /**/