CTRL-A and CTRL-X does not update '[, '] mark. I think they should update
the
'[, '] mark because they change the text. I wrote patch fot it. Please
check
the attached patch.
--
Yukihiro Nakadaira - [email protected]
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/ops.c b/src/ops.c
index 62d88a7..7fda2c7 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -5407,6 +5407,8 @@ do_addsub(command, Prenum1, g_cmd)
int did_change = FALSE;
pos_T t = curwin->w_cursor;
int maxlen = 0;
+ pos_T startpos;
+ pos_T endpos;
dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); /* "heX" */
dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); /* "Octal" */
@@ -5581,9 +5583,12 @@ do_addsub(command, Prenum1, g_cmd)
#endif
}
curwin->w_cursor.col = col;
+ if (!did_change)
+ startpos = curwin->w_cursor;
did_change = TRUE;
(void)del_char(FALSE);
ins_char(firstdigit);
+ endpos = curwin->w_cursor;
curwin->w_cursor.col = col;
}
else
@@ -5673,6 +5678,8 @@ do_addsub(command, Prenum1, g_cmd)
* Delete the old number.
*/
curwin->w_cursor.col = col;
+ if (!did_change)
+ startpos = curwin->w_cursor;
did_change = TRUE;
todel = length;
c = gchar_cursor();
@@ -5747,6 +5754,7 @@ do_addsub(command, Prenum1, g_cmd)
STRCAT(buf1, buf2);
ins_str(buf1); /* insert the new number */
vim_free(buf1);
+ endpos = curwin->w_cursor;
if (lnum < lnume)
curwin->w_cursor.col = t.col;
else if (did_change && curwin->w_cursor.col)
@@ -5776,6 +5784,13 @@ do_addsub(command, Prenum1, g_cmd)
if (visual)
/* cursor at the top of the selection */
curwin->w_cursor = VIsual;
+ if (did_change)
+ {
+ curbuf->b_op_start = startpos;
+ curbuf->b_op_end = endpos;
+ if (curbuf->b_op_end.col > 0)
+ --curbuf->b_op_end.col;
+ }
return OK;
}
diff --git a/src/testdir/test_marks.in b/src/testdir/test_marks.in
index 341f3ac..23c2fb6 100644
--- a/src/testdir/test_marks.in
+++ b/src/testdir/test_marks.in
@@ -8,11 +8,27 @@ STARTTEST
madduu
:let a = string(getpos("'a"))
:$put ='Mark after delete-undo-redo-undo: '.a
-:/^\t/,$wq! test.out
+:''
ENDTEST
textline A
textline B
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:
diff --git a/src/testdir/test_marks.ok b/src/testdir/test_marks.ok
index dd1a3e4..e6c02ee 100644
--- a/src/testdir/test_marks.ok
+++ b/src/testdir/test_marks.ok
@@ -1,6 +1,16 @@
+Tests for marks.
+
+
textline A
textline B
textline C
+
+CTRL-A CTRL-X:
+AAA 123 123
+123 XXXXXXX
+XXX 123 123
+
+
Results:
Mark after delete-undo-redo-undo: [0, 15, 2, 0]