# HG changeset patch # User Christian Brabandt # Date 1512491405 -3600 # Node ID 973a0037f4c3a390c84d41b8eea708a96748b5bd # Parent 814c18a298a92265d513c4ca164d4cd2025c4648 patch 8.0.1374: CTRL-A does not work with an empty line commit https://github.com/vim/vim/commit/5fe6bdf858a7f2f288d599ffb5efb3c08449c817 Author: Bram Moolenaar Date: Tue Dec 5 17:22:12 2017 +0100 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 https://github.com/vim/vim/issues/2387) diff --git a/src/ops.c b/src/ops.c --- a/src/ops.c +++ b/src/ops.c @@ -5433,7 +5433,7 @@ op_addsub( } else /* oap->motion_type == MCHAR */ { - if (!oap->inclusive) + if (pos.lnum == oap->start.lnum && !oap->inclusive) dec(&(oap->end)); length = (colnr_T)STRLEN(ml_get(pos.lnum)); pos.col = 0; diff --git a/src/testdir/test_increment.vim b/src/testdir/test_increment.vim --- a/src/testdir/test_increment.vim +++ b/src/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\" call assert_equal(["111"], getline(1, '$')) call assert_equal([0, 1, 2, 0], getpos('.')) + + call setline(1, ["019"]) + exec "norm! 0vl\" + call assert_equal("029", getline(1)) + + call setline(1, ["01239"]) + exec "norm! 0vlll\" + call assert_equal("01249", getline(1)) + + call setline(1, ["01299"]) + exec "norm! 0vlll\" + 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\" + call assert_equal(['1', '1', '1', '1', '1', '1', ''], getline(1, 7)) + bwipe! +endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -772,6 +772,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1374, +/**/ 1373, /**/ 1372,