diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-04-28 18:57:11 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-05-03 13:16:37 -0400 |
commit | a576bf6196a66a0542af82c51e77e51d90a80c67 (patch) | |
tree | 1cda3beef844b1040a9541a31b73867d044d9314 | |
parent | 501ef952983dba09b160d2e910d3842364502d7c (diff) | |
download | rneovim-a576bf6196a66a0542af82c51e77e51d90a80c67.tar.gz rneovim-a576bf6196a66a0542af82c51e77e51d90a80c67.tar.bz2 rneovim-a576bf6196a66a0542af82c51e77e51d90a80c67.zip |
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)
https://github.com/vim/vim/commit/0e71704b77a9891ccae9f5a9c7429e933078f232
-rw-r--r-- | src/nvim/ex_docmd.c | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 13 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 3f7d616b8f..5bf6aa73c6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2476,8 +2476,11 @@ 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 - check_cursor(); + // 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; diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 7f1e1f4456..2c7d64f078 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -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 |