Skip to content

Commit

Permalink
updated for version 7.4.616
Browse files Browse the repository at this point in the history
Problem:    Cannot insert a tab in front of a block.
Solution:   Correctly compute aop->start. (Christian Brabandt)
  • Loading branch information
brammool committed Feb 3, 2015
1 parent e71eea8 commit f2c03d7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/ops.c
Expand Up @@ -2544,6 +2544,7 @@ op_insert(oap, count1)
char_u *firstline, *ins_text; char_u *firstline, *ins_text;
struct block_def bd; struct block_def bd;
int i; int i;
pos_T t1;


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


t1 = oap->start;
edit(NUL, FALSE, (linenr_T)count1); 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 /* If user has moved off this line, we don't know what to do, so do
* nothing. * nothing.
* Also don't repeat the insert when Insert mode ended with CTRL-C. */ * Also don't repeat the insert when Insert mode ended with CTRL-C. */
Expand All @@ -2644,10 +2653,11 @@ op_insert(oap, count1)
#endif #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; oap->start.col = curbuf->b_op_start_orig.col;
pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) pre_textlen -= t - oap->start_vcol;
- oap->start_vcol; oap->start_vcol = t;
oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
} }
else if (oap->op_type == OP_APPEND else if (oap->op_type == OP_APPEND
&& oap->end.col && oap->end.col
Expand All @@ -2660,12 +2670,13 @@ op_insert(oap, count1)
#endif #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; oap->start.col = curbuf->b_op_start_orig.col;
/* reset pre_textlen to the value of OP_INSERT */ /* reset pre_textlen to the value of OP_INSERT */
pre_textlen += bd.textlen; pre_textlen += bd.textlen;
pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) pre_textlen -= t - oap->start_vcol;
- oap->start_vcol; oap->start_vcol = t;
oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
oap->op_type = OP_INSERT; oap->op_type = OP_INSERT;
} }
} }
Expand Down
10 changes: 10 additions & 0 deletions src/testdir/test39.in
Expand Up @@ -2,6 +2,10 @@
Test Visual block mode commands Test Visual block mode commands
And test "U" in Visual mode, also on German sharp S. And test "U" in Visual mode, also on German sharp S.


#define BO_ALL 0x0001
#define BO_BS 0x0002
#define BO_CRSR 0x0004

STARTTEST STARTTEST
:so small.vim :so small.vim
:so mbyte.vim :so mbyte.vim
Expand Down Expand Up @@ -70,6 +74,12 @@ G3o987652k02l2jr
:exe ":norm! 2k\<C-V>$gj\<Esc>" :exe ":norm! 2k\<C-V>$gj\<Esc>"
:let cpos=getpos("'>") :let cpos=getpos("'>")
:$put ='col:'.cpos[2].' off:'.cpos[3] :$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 :/^the/,$w >> test.out
:qa! :qa!
ENDTEST ENDTEST
Expand Down
Binary file modified src/testdir/test39.ok
Binary file not shown.
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -741,6 +741,8 @@ static char *(features[]) =


static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
616,
/**/ /**/
615, 615,
/**/ /**/
Expand Down

0 comments on commit f2c03d7

Please sign in to comment.