]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
updated for version 7.4.616 v7.4.616
authorBram Moolenaar <Bram@vim.org>
Tue, 3 Feb 2015 17:36:44 +0000 (18:36 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 3 Feb 2015 17:36:44 +0000 (18:36 +0100)
Problem:    Cannot insert a tab in front of a block.
Solution:   Correctly compute aop->start. (Christian Brabandt)

src/ops.c
src/testdir/test39.in
src/testdir/test39.ok
src/version.c

index a4261cb56e856fd5b9d17efc19b17392beb14ce8..856133c8e2edc25347f7cd0b93f4c363e3b249f8 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -2544,6 +2544,7 @@ op_insert(oap, count1)
     char_u             *firstline, *ins_text;
     struct block_def   bd;
     int                        i;
+    pos_T              t1;
 
     /* edit() changes this - record it for OP_APPEND */
     bd.is_MAX = (curwin->w_curswant == MAXCOL);
@@ -2617,8 +2618,16 @@ op_insert(oap, count1)
        }
     }
 
+    t1 = oap->start;
     edit(NUL, FALSE, (linenr_T)count1);
 
+    /* When a tab was inserted, and the characters in front of the tab
+     * have been converted to a tab as well, the column of the cursor
+     * might have actually been reduced, so need to adjust here. */
+    if (t1.lnum == curbuf->b_op_start_orig.lnum
+           && lt(curbuf->b_op_start_orig, t1))
+       oap->start = curbuf->b_op_start_orig;
+
     /* If user has moved off this line, we don't know what to do, so do
      * nothing.
      * Also don't repeat the insert when Insert mode ended with CTRL-C. */
@@ -2644,10 +2653,11 @@ op_insert(oap, count1)
 #endif
                        )
            {
+               int t = getviscol2(curbuf->b_op_start_orig.col,
+                                             curbuf->b_op_start_orig.coladd);
                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);
+               pre_textlen -= t - oap->start_vcol;
+               oap->start_vcol = t;
            }
            else if (oap->op_type == OP_APPEND
                      && oap->end.col
@@ -2660,12 +2670,13 @@ op_insert(oap, count1)
 #endif
                        )
            {
+               int t = getviscol2(curbuf->b_op_start_orig.col,
+                                             curbuf->b_op_start_orig.coladd);
                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)
-                                                           - oap->start_vcol;
-               oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
+               pre_textlen -= t - oap->start_vcol;
+               oap->start_vcol = t;
                oap->op_type = OP_INSERT;
            }
        }
index c4e46fff262d09a0e718a879f7c81bfd4d44d37a..fcb935de72bbdc34a041113612b3f9d2bb1bc3bf 100644 (file)
@@ -2,6 +2,10 @@
 Test Visual block mode commands
 And test "U" in Visual mode, also on German sharp S.
 
+#define BO_ALL     0x0001
+#define BO_BS      0x0002
+#define BO_CRSR            0x0004
+
 STARTTEST
 :so small.vim
 :so mbyte.vim
@@ -70,6 +74,12 @@ G3o98765\e2k02l\162jr\16
 :exe ":norm! 2k\<C-V>$gj\<Esc>"
 :let cpos=getpos("'>")
 :$put ='col:'.cpos[2].' off:'.cpos[3]
+:"
+:" block_insert when replacing spaces in front of the block with tabs
+:set ts=8 sts=4 sw=4
+:4,7y
+Gp
+:exe ":norm! f0\<C-V>2jI\<tab>\<esc>"
 :/^the/,$w >> test.out
 :qa!
 ENDTEST
index 5c517e2223d5c830ca8297b7c8ec71d180777d82..349d67fe775b797974d039d14e918edecdee245f 100644 (file)
Binary files a/src/testdir/test39.ok and b/src/testdir/test39.ok differ
index f278cdace2ce8d706a517acdfa1eafa62a4701b2..2c21e4a7d5360d8f68b18d8edbd550ff8780896d 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    616,
 /**/
     615,
 /**/