mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
vim-patch:7.4.1085
Problem: The CTRL-A and CTRL-X commands do not update the '[ and '] marks.
Solution: (Yukihiro Nakadaira)
a52dfaed10
This commit is contained in:
@@ -4217,6 +4217,8 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
|
|||||||
bool did_change = false;
|
bool did_change = false;
|
||||||
pos_T t = curwin->w_cursor;
|
pos_T t = curwin->w_cursor;
|
||||||
int maxlen = 0;
|
int maxlen = 0;
|
||||||
|
pos_T startpos;
|
||||||
|
pos_T endpos;
|
||||||
|
|
||||||
dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); // "heX"
|
dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); // "heX"
|
||||||
dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); // "Octal"
|
dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); // "Octal"
|
||||||
@@ -4393,9 +4395,13 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
curwin->w_cursor.col = col;
|
curwin->w_cursor.col = col;
|
||||||
|
if (!did_change) {
|
||||||
|
startpos = curwin->w_cursor;
|
||||||
|
}
|
||||||
did_change = true;
|
did_change = true;
|
||||||
(void)del_char(false);
|
(void)del_char(false);
|
||||||
ins_char(firstdigit);
|
ins_char(firstdigit);
|
||||||
|
endpos = curwin->w_cursor;
|
||||||
curwin->w_cursor.col = col;
|
curwin->w_cursor.col = col;
|
||||||
} else {
|
} else {
|
||||||
if (col > 0 && ptr[col - 1] == '-' && !visual) {
|
if (col > 0 && ptr[col - 1] == '-' && !visual) {
|
||||||
@@ -4477,6 +4483,9 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
|
|||||||
|
|
||||||
// Delete the old number.
|
// Delete the old number.
|
||||||
curwin->w_cursor.col = col;
|
curwin->w_cursor.col = col;
|
||||||
|
if (!did_change) {
|
||||||
|
startpos = curwin->w_cursor;
|
||||||
|
}
|
||||||
did_change = true;
|
did_change = true;
|
||||||
todel = length;
|
todel = length;
|
||||||
c = gchar_cursor();
|
c = gchar_cursor();
|
||||||
@@ -4559,6 +4568,7 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
|
|||||||
STRCAT(buf1, buf2);
|
STRCAT(buf1, buf2);
|
||||||
ins_str(buf1); // insert the new number
|
ins_str(buf1); // insert the new number
|
||||||
xfree(buf1);
|
xfree(buf1);
|
||||||
|
endpos = curwin->w_cursor;
|
||||||
if (lnum < lnume) {
|
if (lnum < lnume) {
|
||||||
curwin->w_cursor.col = t.col;
|
curwin->w_cursor.col = t.col;
|
||||||
} else if (did_change && curwin->w_cursor.col) {
|
} else if (did_change && curwin->w_cursor.col) {
|
||||||
@@ -4586,6 +4596,14 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
|
|||||||
// cursor at the top of the selection
|
// cursor at the top of the selection
|
||||||
curwin->w_cursor = VIsual;
|
curwin->w_cursor = VIsual;
|
||||||
}
|
}
|
||||||
|
if (did_change) {
|
||||||
|
// set the '[ and '] marks
|
||||||
|
curbuf->b_op_start = startpos;
|
||||||
|
curbuf->b_op_end = endpos;
|
||||||
|
if (curbuf->b_op_end.col > 0) {
|
||||||
|
curbuf->b_op_end.col--;
|
||||||
|
}
|
||||||
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,11 +8,27 @@ STARTTEST
|
|||||||
madduu
|
madduu
|
||||||
:let a = string(getpos("'a"))
|
:let a = string(getpos("'a"))
|
||||||
:$put ='Mark after delete-undo-redo-undo: '.a
|
:$put ='Mark after delete-undo-redo-undo: '.a
|
||||||
:/^\t/,$wq! test.out
|
:''
|
||||||
ENDTEST
|
ENDTEST
|
||||||
|
|
||||||
textline A
|
textline A
|
||||||
textline B
|
textline B
|
||||||
textline C
|
textline C
|
||||||
|
|
||||||
|
STARTTEST
|
||||||
|
:" test that CTRL-A and CTRL-X updates last changed mark '[, '].
|
||||||
|
:/^123/
|
||||||
|
:execute "normal! \<C-A>`[v`]rAjwvjw\<C-X>`[v`]rX"
|
||||||
|
ENDTEST
|
||||||
|
|
||||||
|
CTRL-A CTRL-X:
|
||||||
|
123 123 123
|
||||||
|
123 123 123
|
||||||
|
123 123 123
|
||||||
|
|
||||||
|
STARTTEST
|
||||||
|
:g/^STARTTEST/.,/^ENDTEST/d
|
||||||
|
:wq! test.out
|
||||||
|
ENDTEST
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
|
@@ -1,6 +1,16 @@
|
|||||||
|
Tests for marks.
|
||||||
|
|
||||||
|
|
||||||
textline A
|
textline A
|
||||||
textline B
|
textline B
|
||||||
textline C
|
textline C
|
||||||
|
|
||||||
|
|
||||||
|
CTRL-A CTRL-X:
|
||||||
|
AAA 123 123
|
||||||
|
123 XXXXXXX
|
||||||
|
XXX 123 123
|
||||||
|
|
||||||
|
|
||||||
Results:
|
Results:
|
||||||
Mark after delete-undo-redo-undo: [0, 15, 2, 0]
|
Mark after delete-undo-redo-undo: [0, 15, 2, 0]
|
||||||
|
@@ -73,6 +73,7 @@ static int included_patches[] = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
1085,
|
||||||
1084,
|
1084,
|
||||||
// 1083,
|
// 1083,
|
||||||
// 1082,
|
// 1082,
|
||||||
|
Reference in New Issue
Block a user