Skip to content

Commit 7ae4136

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 616c7a5 + ef2b503 commit 7ae4136

File tree

4 files changed

+39
-29
lines changed

4 files changed

+39
-29
lines changed

src/normal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4232,6 +4232,7 @@ nv_addsub(cap)
42324232
{
42334233
if (!VIsual_active && cap->oap->op_type == OP_NOP)
42344234
{
4235+
prep_redo_cmd(cap);
42354236
cap->oap->op_type = cap->cmdchar == Ctrl_A ? OP_NR_ADD : OP_NR_SUB;
42364237
op_addsub(cap->oap, cap->count1, cap->arg);
42374238
cap->oap->op_type = OP_NOP;

src/ops.c

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5371,9 +5371,9 @@ op_addsub(oap, Prenum1, g_cmd)
53715371
}
53725372
else
53735373
{
5374-
int one_change;
5375-
int length;
5376-
pos_T startpos;
5374+
int one_change;
5375+
int length;
5376+
pos_T startpos;
53775377

53785378
if (u_save((linenr_T)(oap->start.lnum - 1),
53795379
(linenr_T)(oap->end.lnum + 1)) == FAIL)
@@ -5388,32 +5388,29 @@ op_addsub(oap, Prenum1, g_cmd)
53885388
pos.col = bd.textcol;
53895389
length = bd.textlen;
53905390
}
5391-
else
5391+
else if (oap->motion_type == MLINE)
5392+
{
5393+
curwin->w_cursor.col = 0;
5394+
pos.col = 0;
5395+
length = (colnr_T)STRLEN(ml_get(pos.lnum));
5396+
}
5397+
else /* oap->motion_type == MCHAR */
53925398
{
5393-
if (oap->motion_type == MLINE)
5399+
if (!oap->inclusive)
5400+
dec(&(oap->end));
5401+
length = (colnr_T)STRLEN(ml_get(pos.lnum));
5402+
pos.col = 0;
5403+
if (pos.lnum == oap->start.lnum)
53945404
{
5395-
curwin->w_cursor.col = 0;
5396-
pos.col = 0;
5397-
length = (colnr_T)STRLEN(ml_get(pos.lnum));
5405+
pos.col += oap->start.col;
5406+
length -= oap->start.col;
53985407
}
5399-
else if (oap->motion_type == MCHAR)
5408+
if (pos.lnum == oap->end.lnum)
54005409
{
5401-
if (!oap->inclusive)
5402-
dec(&(oap->end));
5403-
length = (colnr_T)STRLEN(ml_get(pos.lnum));
5404-
pos.col = 0;
5405-
if (pos.lnum == oap->start.lnum)
5406-
{
5407-
pos.col += oap->start.col;
5408-
length -= oap->start.col;
5409-
}
5410-
if (pos.lnum == oap->end.lnum)
5411-
{
5412-
length = (int)STRLEN(ml_get(oap->end.lnum));
5413-
if (oap->end.col >= length)
5414-
oap->end.col = length - 1;
5415-
length = oap->end.col - pos.col + 1;
5416-
}
5410+
length = (int)STRLEN(ml_get(oap->end.lnum));
5411+
if (oap->end.col >= length)
5412+
oap->end.col = length - 1;
5413+
length = oap->end.col - pos.col + 1;
54175414
}
54185415
}
54195416
one_change = do_addsub(oap->op_type, &pos, length, amount);
@@ -5493,7 +5490,7 @@ do_addsub(op_type, pos, length, Prenum1)
54935490
int was_positive = TRUE;
54945491
int visual = VIsual_active;
54955492
int did_change = FALSE;
5496-
pos_T t = curwin->w_cursor;
5493+
pos_T save_cursor = curwin->w_cursor;
54975494
int maxlen = 0;
54985495
pos_T startpos;
54995496
pos_T endpos;
@@ -5819,9 +5816,6 @@ do_addsub(op_type, pos, length, Prenum1)
58195816
--curwin->w_cursor.col;
58205817
}
58215818

5822-
theend:
5823-
if (visual)
5824-
curwin->w_cursor = t;
58255819
if (did_change)
58265820
{
58275821
/* set the '[ and '] marks */
@@ -5831,6 +5825,10 @@ do_addsub(op_type, pos, length, Prenum1)
58315825
--curbuf->b_op_end.col;
58325826
}
58335827

5828+
theend:
5829+
if (visual)
5830+
curwin->w_cursor = save_cursor;
5831+
58345832
return did_change;
58355833
}
58365834

src/testdir/test_increment.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,4 +701,11 @@ func Test_visual_increment_37()
701701
call assert_equal(["1 26", "4 59"], getline(1, 2))
702702
endfunc
703703

704+
" Check redo after the normal mode increment
705+
func Test_visual_increment_38()
706+
exec "norm! i10\<ESC>5\<C-A>."
707+
call assert_equal(["20"], getline(1, '$'))
708+
call assert_equal([0, 1, 2, 0], getpos('.'))
709+
endfunc
710+
704711
" vim: tabstop=2 shiftwidth=2 expandtab

src/version.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,10 @@ static char *(features[]) =
756756

757757
static int included_patches[] =
758758
{ /* Add new patch number below this line */
759+
/**/
760+
1089,
761+
/**/
762+
1088,
759763
/**/
760764
1087,
761765
/**/

0 commit comments

Comments
 (0)