Skip to content

Commit a52dfae

Browse files
committed
patch 7.4.1085
Problem: The CTRL-A and CTRL-X commands do not update the '[ and '] marks. Solution: (Yukihiro Nakadaira)
1 parent e1edc1c commit a52dfae

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

src/ops.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5382,6 +5382,8 @@ do_addsub(command, Prenum1, g_cmd)
53825382
int pos = 0;
53835383
int bit = 0;
53845384
int bits = sizeof(unsigned long) * 8;
5385+
pos_T startpos;
5386+
pos_T endpos;
53855387

53865388
dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); /* "heX" */
53875389
dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); /* "Octal" */
@@ -5582,9 +5584,12 @@ do_addsub(command, Prenum1, g_cmd)
55825584
#endif
55835585
}
55845586
curwin->w_cursor.col = col;
5587+
if (!did_change)
5588+
startpos = curwin->w_cursor;
55855589
did_change = TRUE;
55865590
(void)del_char(FALSE);
55875591
ins_char(firstdigit);
5592+
endpos = curwin->w_cursor;
55885593
curwin->w_cursor.col = col;
55895594
}
55905595
else
@@ -5677,6 +5682,8 @@ do_addsub(command, Prenum1, g_cmd)
56775682
* Delete the old number.
56785683
*/
56795684
curwin->w_cursor.col = col;
5685+
if (!did_change)
5686+
startpos = curwin->w_cursor;
56805687
did_change = TRUE;
56815688
todel = length;
56825689
c = gchar_cursor();
@@ -5763,6 +5770,7 @@ do_addsub(command, Prenum1, g_cmd)
57635770
STRCAT(buf1, buf2);
57645771
ins_str(buf1); /* insert the new number */
57655772
vim_free(buf1);
5773+
endpos = curwin->w_cursor;
57665774
if (lnum < lnume)
57675775
curwin->w_cursor.col = t.col;
57685776
else if (did_change && curwin->w_cursor.col)
@@ -5788,6 +5796,14 @@ do_addsub(command, Prenum1, g_cmd)
57885796
if (visual)
57895797
/* cursor at the top of the selection */
57905798
curwin->w_cursor = VIsual;
5799+
if (did_change)
5800+
{
5801+
/* set the '[ and '] marks */
5802+
curbuf->b_op_start = startpos;
5803+
curbuf->b_op_end = endpos;
5804+
if (curbuf->b_op_end.col > 0)
5805+
--curbuf->b_op_end.col;
5806+
}
57915807
return OK;
57925808
}
57935809

src/testdir/test_marks.in

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,27 @@ STARTTEST
88
madduu
99
:let a = string(getpos("'a"))
1010
:$put ='Mark after delete-undo-redo-undo: '.a
11-
:/^\t/,$wq! test.out
11+
:''
1212
ENDTEST
1313

1414
textline A
1515
textline B
1616
textline C
1717

18+
STARTTEST
19+
:" test that CTRL-A and CTRL-X updates last changed mark '[, '].
20+
:/^123/
21+
:execute "normal! \<C-A>`[v`]rAjwvjw\<C-X>`[v`]rX"
22+
ENDTEST
23+
24+
CTRL-A CTRL-X:
25+
123 123 123
26+
123 123 123
27+
123 123 123
28+
29+
STARTTEST
30+
:g/^STARTTEST/.,/^ENDTEST/d
31+
:wq! test.out
32+
ENDTEST
33+
1834
Results:

src/testdir/test_marks.ok

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
Tests for marks.
2+
3+
14
textline A
25
textline B
36
textline C
47

8+
9+
CTRL-A CTRL-X:
10+
AAA 123 123
11+
123 XXXXXXX
12+
XXX 123 123
13+
14+
515
Results:
616
Mark after delete-undo-redo-undo: [0, 15, 2, 0]

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+
1085,
744746
/**/
745747
1084,
746748
/**/

0 commit comments

Comments
 (0)