Skip to content

Commit 0a0b28c

Browse files
brammooldouglasdrumond
authored andcommitted
updated for version 7.4.616
Problem: Cannot insert a tab in front of a block. Solution: Correctly compute aop->start. (Christian Brabandt)
1 parent 5f0e409 commit 0a0b28c

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

src/ops.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2544,6 +2544,7 @@ op_insert(oap, count1)
25442544
char_u *firstline, *ins_text;
25452545
struct block_def bd;
25462546
int i;
2547+
pos_T t1;
25472548

25482549
/* edit() changes this - record it for OP_APPEND */
25492550
bd.is_MAX = (curwin->w_curswant == MAXCOL);
@@ -2617,8 +2618,16 @@ op_insert(oap, count1)
26172618
}
26182619
}
26192620

2621+
t1 = oap->start;
26202622
edit(NUL, FALSE, (linenr_T)count1);
26212623

2624+
/* When a tab was inserted, and the characters in front of the tab
2625+
* have been converted to a tab as well, the column of the cursor
2626+
* might have actually been reduced, so need to adjust here. */
2627+
if (t1.lnum == curbuf->b_op_start_orig.lnum
2628+
&& lt(curbuf->b_op_start_orig, t1))
2629+
oap->start = curbuf->b_op_start_orig;
2630+
26222631
/* If user has moved off this line, we don't know what to do, so do
26232632
* nothing.
26242633
* Also don't repeat the insert when Insert mode ended with CTRL-C. */
@@ -2644,10 +2653,11 @@ op_insert(oap, count1)
26442653
#endif
26452654
)
26462655
{
2656+
int t = getviscol2(curbuf->b_op_start_orig.col,
2657+
curbuf->b_op_start_orig.coladd);
26472658
oap->start.col = curbuf->b_op_start_orig.col;
2648-
pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
2649-
- oap->start_vcol;
2650-
oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
2659+
pre_textlen -= t - oap->start_vcol;
2660+
oap->start_vcol = t;
26512661
}
26522662
else if (oap->op_type == OP_APPEND
26532663
&& oap->end.col
@@ -2660,12 +2670,13 @@ op_insert(oap, count1)
26602670
#endif
26612671
)
26622672
{
2673+
int t = getviscol2(curbuf->b_op_start_orig.col,
2674+
curbuf->b_op_start_orig.coladd);
26632675
oap->start.col = curbuf->b_op_start_orig.col;
26642676
/* reset pre_textlen to the value of OP_INSERT */
26652677
pre_textlen += bd.textlen;
2666-
pre_textlen -= getviscol2(oap->start.col, oap->start.coladd)
2667-
- oap->start_vcol;
2668-
oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
2678+
pre_textlen -= t - oap->start_vcol;
2679+
oap->start_vcol = t;
26692680
oap->op_type = OP_INSERT;
26702681
}
26712682
}

src/testdir/test39.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Test Visual block mode commands
33
And test "U" in Visual mode, also on German sharp S.
44

5+
#define BO_ALL 0x0001
6+
#define BO_BS 0x0002
7+
#define BO_CRSR 0x0004
8+
59
STARTTEST
610
:so small.vim
711
:so mbyte.vim
@@ -70,6 +74,12 @@ G3o987652k02l2jr
7074
:exe ":norm! 2k\<C-V>$gj\<Esc>"
7175
:let cpos=getpos("'>")
7276
:$put ='col:'.cpos[2].' off:'.cpos[3]
77+
:"
78+
:" block_insert when replacing spaces in front of the block with tabs
79+
:set ts=8 sts=4 sw=4
80+
:4,7y
81+
Gp
82+
:exe ":norm! f0\<C-V>2jI\<tab>\<esc>"
7383
:/^the/,$w >> test.out
7484
:qa!
7585
ENDTEST

src/testdir/test39.ok

78 Bytes
Binary file not shown.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
616,
744746
/**/
745747
615,
746748
/**/

0 commit comments

Comments
 (0)