summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2015-08-04 18:23:22 +0200
committerBram Moolenaar <bram@vim.org>2015-08-04 18:23:22 +0200
commit55a2387a1587ca270faf170b04ef6d4dfa8ad6f5 (patch)
treee9ec69de40724b065e866b0bfa89019baa97aaac /src
parent19bf9ba5a4fa3dbb08a88a7ae335d2dbe6d859cb (diff)
downloadvim-55a2387a1587ca270faf170b04ef6d4dfa8ad6f5.tar.gz
patch 7.4.806v7.4.806v7-4-806
Problem: CTRL-A in Visual mode doesn't work properly with "alpha" in 'nrformat'. Solution: Make it work. (Christian Brabandt)
Diffstat (limited to 'src')
-rw-r--r--src/ops.c39
-rw-r--r--src/testdir/test_increment.in24
-rw-r--r--src/testdir/test_increment.ok9
-rw-r--r--src/version.c2
4 files changed, 54 insertions, 20 deletions
diff --git a/src/ops.c b/src/ops.c
index ff722589..f53567bc 100644
--- 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.
*/
diff --git a/src/testdir/test_increment.in b/src/testdir/test_increment.in
index 916f77e8..fb7e6e3e 100644
--- a/src/testdir/test_increment.in
+++ b/src/testdir/test_increment.in
@@ -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
:/^E18=/+put a
V3kg..
+:" Test 19
+:set nrformats+=alpha
+:/^S19=/+,/^E19=/-y a
+:/^E19=/+put a
+k$
+:set nrformats&vim
+
:" Save the report
:/^# Test 1/,$w! test.out
:qa!
@@ -547,6 +564,13 @@ E18====
+# Test 19
+S19====
+1
+1a
+E19====
+
+
ENDTEST
diff --git a/src/testdir/test_increment.ok b/src/testdir/test_increment.ok
index 6ca0acce..685478e6 100644
--- a/src/testdir/test_increment.ok
+++ b/src/testdir/test_increment.ok
@@ -261,6 +261,15 @@ E18====
12
+# Test 19
+S19====
+1
+1a
+E19====
+
+2
+2a
+
ENDTEST
diff --git a/src/version.c b/src/version.c
index 01fb7a8e..714851b2 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 806,
+/**/
805,
/**/
804,