Skip to content

Commit 5fe6bdf

Browse files
committed
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 #2387)
1 parent 3767c6e commit 5fe6bdf

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5433,7 +5433,7 @@ op_addsub(
54335433
}
54345434
else /* oap->motion_type == MCHAR */
54355435
{
5436-
if (!oap->inclusive)
5436+
if (pos.lnum == oap->start.lnum && !oap->inclusive)
54375437
dec(&(oap->end));
54385438
length = (colnr_T)STRLEN(ml_get(pos.lnum));
54395439
pos.col = 0;

src/testdir/test_increment.vim

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,25 @@ endfunc
364364
" Expected:
365365
" 1) Ctrl-a on visually selected zero
366366
" 111
367+
"
368+
" Also: 019 with "01" selected increments to "029".
367369
func Test_visual_increment_15()
368370
call setline(1, ["101"])
369371
exec "norm! lv\<C-A>"
370372
call assert_equal(["111"], getline(1, '$'))
371373
call assert_equal([0, 1, 2, 0], getpos('.'))
374+
375+
call setline(1, ["019"])
376+
exec "norm! 0vl\<C-A>"
377+
call assert_equal("029", getline(1))
378+
379+
call setline(1, ["01239"])
380+
exec "norm! 0vlll\<C-A>"
381+
call assert_equal("01249", getline(1))
382+
383+
call setline(1, ["01299"])
384+
exec "norm! 0vlll\<C-A>"
385+
call assert_equal("1309", getline(1))
372386
endfunc
373387

374388
" 16) increment right aligned numbers
@@ -756,5 +770,12 @@ func Test_normal_increment_03()
756770
call assert_equal([0, 3, 25, 0], getpos('.'))
757771
endfunc
758772

773+
func Test_increment_empty_line()
774+
new
775+
call setline(1, ['0', '0', '0', '0', '0', '0', ''])
776+
exe "normal Gvgg\<C-A>"
777+
call assert_equal(['1', '1', '1', '1', '1', '1', ''], getline(1, 7))
778+
bwipe!
779+
endfunc
759780

760781
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1374,
774776
/**/
775777
1373,
776778
/**/

0 commit comments

Comments
 (0)