aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-09-16 10:23:27 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-09-16 10:24:59 -0400
commit3c3c733c3cf94aab6e174ad834acae3f86f8309f (patch)
tree386d50048759236b2ab322e2ada004713a35ecbb /src
parentb2d7b70f4ddd043a7f0f905c74f7d7e2e2a81ebb (diff)
downloadrneovim-3c3c733c3cf94aab6e174ad834acae3f86f8309f.tar.gz
rneovim-3c3c733c3cf94aab6e174ad834acae3f86f8309f.tar.bz2
rneovim-3c3c733c3cf94aab6e174ad834acae3f86f8309f.zip
vim-patch:8.0.1374: CTRL-A does not work with an empty line
Problem: CTRL-A does not work with an empty line. (Alex) Solution: Decrement the end only once. (Hirohito Higashi, closes vim/vim#2387) https://github.com/vim/vim/commit/5fe6bdf858a7f2f288d599ffb5efb3c08449c817
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ops.c2
-rw-r--r--src/nvim/testdir/test_increment.vim21
2 files changed, 22 insertions, 1 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index d28e51ba4d..e902127a40 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -4418,7 +4418,7 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd)
length = (colnr_T)STRLEN(ml_get(pos.lnum));
} else {
// oap->motion_type == kMTCharWise
- if (!oap->inclusive) {
+ if (pos.lnum == oap->start.lnum && !oap->inclusive) {
dec(&(oap->end));
}
length = (colnr_T)STRLEN(ml_get(pos.lnum));
diff --git a/src/nvim/testdir/test_increment.vim b/src/nvim/testdir/test_increment.vim
index 8bfd95d810..ad355dce9b 100644
--- a/src/nvim/testdir/test_increment.vim
+++ b/src/nvim/testdir/test_increment.vim
@@ -364,11 +364,25 @@ endfunc
" Expected:
" 1) Ctrl-a on visually selected zero
" 111
+"
+" Also: 019 with "01" selected increments to "029".
func Test_visual_increment_15()
call setline(1, ["101"])
exec "norm! lv\<C-A>"
call assert_equal(["111"], getline(1, '$'))
call assert_equal([0, 1, 2, 0], getpos('.'))
+
+ call setline(1, ["019"])
+ exec "norm! 0vl\<C-A>"
+ call assert_equal("029", getline(1))
+
+ call setline(1, ["01239"])
+ exec "norm! 0vlll\<C-A>"
+ call assert_equal("01249", getline(1))
+
+ call setline(1, ["01299"])
+ exec "norm! 0vlll\<C-A>"
+ call assert_equal("1309", getline(1))
endfunc
" 16) increment right aligned numbers
@@ -756,5 +770,12 @@ func Test_normal_increment_03()
call assert_equal([0, 3, 25, 0], getpos('.'))
endfunc
+func Test_increment_empty_line()
+ new
+ call setline(1, ['0', '0', '0', '0', '0', '0', ''])
+ exe "normal Gvgg\<C-A>"
+ call assert_equal(['1', '1', '1', '1', '1', '1', ''], getline(1, 7))
+ bwipe!
+endfunc
" vim: shiftwidth=2 sts=2 expandtab