aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwatiko <service@mail.watiko.net>2016-01-14 21:33:00 +0900
committerwatiko <service@mail.watiko.net>2016-02-01 03:43:37 +0900
commitd21aaef4560e73d3a1e008abb72924a01fa57c14 (patch)
tree28e44787a142bbc8ca87c7326d3600d103b053c8
parent43fd12629841d459214ead194410d317ef06006c (diff)
downloadrneovim-d21aaef4560e73d3a1e008abb72924a01fa57c14.tar.gz
rneovim-d21aaef4560e73d3a1e008abb72924a01fa57c14.tar.bz2
rneovim-d21aaef4560e73d3a1e008abb72924a01fa57c14.zip
vim-patch:7.4.806
Problem: CTRL-A in Visual mode doesn't work properly with "alpha" in 'nrformat'. Solution: Make it work. (Christian Brabandt) https://github.com/vim/vim/commit/cc218ab3caf983a0dcd3399beb8e1ecfcf0dd25d
-rw-r--r--src/nvim/ops.c43
-rw-r--r--src/nvim/testdir/test_increment.in24
-rw-r--r--src/nvim/testdir/test_increment.ok9
-rw-r--r--src/nvim/version.c2
4 files changed, 54 insertions, 24 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index af38391437..d22dcad020 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -4340,6 +4340,8 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
}
for (int i = lnum; i <= lnume; i++) {
+ colnr_T stop = 0;
+
t = curwin->w_cursor;
curwin->w_cursor.lnum = i;
ptr = get_cursor_line_ptr();
@@ -4349,31 +4351,26 @@ int do_addsub(int command, linenr_T Prenum1, bool g_cmd)
continue;
}
if (visual) {
- if (doalp) {
- // search for ascii chars
- while (!ASCII_ISALPHA(ptr[col]) && ptr[col]) {
- col++;
- }
- } else if (dohex) {
- // skip to first digit, but allow for leading '-'
- while (!(ascii_isxdigit(ptr[col])
- || (ptr[col] == '-' && ascii_isxdigit(ptr[col + 1])))
- && ptr[col]) {
- col++;
- }
- } else {
- // decimal
- while (!(ascii_isdigit(ptr[col])
- || (ptr[col] == '-' && ascii_isdigit(ptr[col + 1])))
- && ptr[col]) {
- col++;
+ 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
+ && !ascii_isdigit(ptr[col])
+ && !(doalp && ASCII_ISALPHA(ptr[col]))) {
+ if (col > 0 && col == stop) {
+ break;
}
+ col++;
+ }
+
+ if (col > startcol && ptr[col - 1] == '-') {
+ 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.
firstdigit = ptr[col];
diff --git a/src/nvim/testdir/test_increment.in b/src/nvim/testdir/test_increment.in
index 916f77e84b..fb7e6e3ee2 100644
--- a/src/nvim/testdir/test_increment.in
+++ b/src/nvim/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/nvim/testdir/test_increment.ok b/src/nvim/testdir/test_increment.ok
index 6ca0acce66..685478e668 100644
--- a/src/nvim/testdir/test_increment.ok
+++ b/src/nvim/testdir/test_increment.ok
@@ -261,6 +261,15 @@ E18====
12
+# Test 19
+S19====
+1
+1a
+E19====
+
+2
+2a
+
ENDTEST
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 0b9468ac6c..9dd943d74b 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -328,7 +328,7 @@ static int included_patches[] = {
809,
// 808 NA
// 807,
- // 806,
+ 806,
// 805,
// 804,
803,