vim-patch:8.2.0648: semicolon search does not work in first line

Problem:    Semicolon search does not work in first line.
Solution:   Allow the cursor to be in line zero. (Christian Brabandt,
            closes vim/vim#5996)
0e71704b77
This commit is contained in:
Jan Edmund Lazo 2020-04-28 18:57:11 -04:00
parent 501ef95298
commit a576bf6196
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 18 additions and 2 deletions

View File

@ -2476,9 +2476,12 @@ int parse_cmd_address(exarg_T *eap, char_u **errormsg)
if (*eap->cmd == ';') {
if (!eap->skip) {
curwin->w_cursor.lnum = eap->line2;
// don't leave the cursor on an illegal line or column
// Don't leave the cursor on an illegal line or column, but do
// accept zero as address, so 0;/PATTERN/ works correctly.
if (eap->line2 > 0) {
check_cursor();
}
}
} else if (*eap->cmd != ',') {
break;
}

View File

@ -801,3 +801,16 @@ func Test_buffers_lastused()
bwipeout bufb
bwipeout bufc
endfunc
" test that ";" works to find a match at the start of the first line
func Test_zero_line_search()
new
call setline(1, ["1, pattern", "2, ", "3, pattern"])
call cursor(1,1)
0;/pattern/d
call assert_equal(["2, ", "3, pattern"], getline(1,'$'))
q!
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab