]> granicus.if.org Git - vim/commitdiff
patch 7.4.1085 v7.4.1085
authorBram Moolenaar <Bram@vim.org>
Sun, 10 Jan 2016 19:21:57 +0000 (20:21 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 10 Jan 2016 19:21:57 +0000 (20:21 +0100)
Problem:    The CTRL-A and CTRL-X commands do not update the '[ and '] marks.
Solution:   (Yukihiro Nakadaira)

src/ops.c
src/testdir/test_marks.in
src/testdir/test_marks.ok
src/version.c

index 12978a829646456bf94a60b7586242cd8607caa5..2dcdb778a37bf718a094cb2364059e5800691799 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -5382,6 +5382,8 @@ do_addsub(command, Prenum1, g_cmd)
     int                pos = 0;
     int                bit = 0;
     int                bits = sizeof(unsigned long) * 8;
+    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" */
@@ -5582,9 +5584,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
@@ -5677,6 +5682,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();
@@ -5763,6 +5770,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)
@@ -5788,6 +5796,14 @@ do_addsub(command, Prenum1, g_cmd)
     if (visual)
        /* cursor at the top of the selection */
        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;
 }
 
index 341f3ac30f7cc0de8f1a49a56a84aa2166815324..23c2fb65fe5a59a672a010b8c553bb3d4be440cd 100644 (file)
@@ -8,11 +8,27 @@ STARTTEST
 maddu\12u
 :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:
index dd1a3e43b51088098a1b24b3d8fff25a41f8de6d..e6c02ee7b04f70e1422892203a4f04f118b87d43 100644 (file)
@@ -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]
index 33eef0107ef6a4097686a0afc0fbf9b4c3d09372..07d2c26319318841f7ae69959cf4b1b185ff1ca4 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1085,
 /**/
     1084,
 /**/