]> granicus.if.org Git - vim/commitdiff
patch 7.4.806 v7.4.806
authorBram Moolenaar <Bram@vim.org>
Tue, 4 Aug 2015 16:23:22 +0000 (18:23 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 4 Aug 2015 16:23:22 +0000 (18:23 +0200)
Problem:    CTRL-A in Visual mode doesn't work properly with "alpha" in
            'nrformat'.
Solution:   Make it work. (Christian Brabandt)

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

index ff722589465f38ef964d001143f7637828aed591..f53567bc104f7cb6011a61efc6c83d74ae14a65e 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -5492,6 +5492,8 @@ do_addsub(command, Prenum1, g_cmd)
 
     for (i = lnum; i <= lnume; i++)
     {
+       colnr_T stop = 0;
+
        t = curwin->w_cursor;
        curwin->w_cursor.lnum = i;
        ptr = ml_get_curline();
@@ -5501,31 +5503,28 @@ do_addsub(command, Prenum1, g_cmd)
            continue;
        if (visual)
        {
-           if (doalp) /* search for ascii chars */
-           {
-               while (!ASCII_ISALPHA(ptr[col]) && ptr[col])
-                   col++;
-           }
-           /* skip to first digit, but allow for leading '-' */
-           else if (dohex)
+           if (VIsual_mode == 'v'
+                   && i == lnume)
+               stop = curwin->w_cursor.col;
+           else if (VIsual_mode == Ctrl_V
+                   && curbuf->b_visual.vi_curswant != MAXCOL)
+               stop = curwin->w_cursor.col;
+
+           while (ptr[col] != NUL
+                   && !vim_isdigit(ptr[col])
+                   && !(doalp && ASCII_ISALPHA(ptr[col])))
            {
-               while (!(vim_isxdigit(ptr[col]) || (ptr[col] == '-'
-                                   && vim_isxdigit(ptr[col+1]))) && ptr[col])
-                   col++;
+               if (col > 0  && col == stop)
+                   break;
+               ++col;
            }
-           else /* decimal */
+
+           if (col > startcol && ptr[col - 1] == '-')
            {
-               while (!(vim_isdigit(ptr[col]) || (ptr[col] == '-'
-                                    && vim_isdigit(ptr[col+1]))) && ptr[col])
-                   col++;
+               negative = TRUE;
+               was_positive = FALSE;
            }
        }
-       if (visual && ptr[col] == '-')
-       {
-           negative = TRUE;
-           was_positive = FALSE;
-           col++;
-       }
        /*
         * If a number was found, and saving for undo works, replace the number.
         */
index 916f77e84bcef8dfbbe48c1151ec034cca047e53..fb7e6e3ee28b397dcd980f9ac8c10e8999746885 100644 (file)
@@ -260,6 +260,16 @@ Text:
   9
   12
   
+19) increment on number with nrformat including alpha
+Text:
+ 1
+ 1a
+
+ Expected:
+ 1) <Ctrl-V>j$ <ctrl-a>
+ 2
+ 1b
+   
 
 
 STARTTEST
@@ -369,6 +379,13 @@ V3k\ 1
 :/^E18=/+put a
 V3kg\ 1..
 
+:" Test 19
+:set nrformats+=alpha
+:/^S19=/+,/^E19=/-y a
+:/^E19=/+put a
+\16k$\ 1
+:set nrformats&vim
+
 :" Save the report
 :/^# Test 1/,$w! test.out
 :qa!
@@ -547,6 +564,13 @@ E18====
 
 
 
+# Test 19
+S19====
+1
+1a
+E19====
+
+
 
 
 ENDTEST
index 6ca0acce667fb843074217a1f0e9743dd90afced..685478e668bfd915d8f01ec48a6790927ce3c883 100644 (file)
@@ -261,6 +261,15 @@ E18====
 12
 
 
+# Test 19
+S19====
+1
+1a
+E19====
+
+2
+2a
+
 
 
 ENDTEST
index 01fb7a8ea6f43f59add54cbaf0040e7e914e95d0..714851b22a97edf98450e963d34469ed937c52c0 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    806,
 /**/
     805,
 /**/