aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-01 17:12:41 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-04-01 17:18:21 +0800
commitb9454d1676999ae44faa070f79b40863e4ea843b (patch)
tree3a2927ec6475311d48da2be51c59f2b5536afa89
parentb8fbd749a9d814f227c26d02f17f805435856677 (diff)
downloadrneovim-b9454d1676999ae44faa070f79b40863e4ea843b.tar.gz
rneovim-b9454d1676999ae44faa070f79b40863e4ea843b.tar.bz2
rneovim-b9454d1676999ae44faa070f79b40863e4ea843b.zip
vim-patch:8.2.3489: ml_get error after search with range
Problem: ml_get error after search with range. Solution: Limit the line number to the buffer line count. https://github.com/vim/vim/commit/35a319b77f897744eec1155b736e9372c9c5575f
-rw-r--r--src/nvim/ex_docmd.c5
-rw-r--r--src/nvim/testdir/test_search.vim14
2 files changed, 17 insertions, 2 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 20325509c4..bb6f3ba395 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -4027,8 +4027,9 @@ static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, in
// When '/' or '?' follows another address, start from
// there.
- if (lnum != MAXLNUM) {
- curwin->w_cursor.lnum = lnum;
+ if (lnum > 0 && lnum != MAXLNUM) {
+ curwin->w_cursor.lnum
+ = lnum > curbuf->b_ml.ml_line_count ? curbuf->b_ml.ml_line_count : lnum;
}
// Start a forward search at the end of the line (unless
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index 040267c136..8154bd9c4d 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -1539,5 +1539,19 @@ func Test_no_last_search_pattern()
call feedkeys("??\<C-T>", 'xt')
endfunc
+func Test_search_with_invalid_range()
+ new
+ let lines =<< trim END
+ /\%.v
+ 5/
+ c
+ END
+ call writefile(lines, 'Xrangesearch')
+ source Xrangesearch
+
+ bwipe!
+ call delete('Xrangesearch')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab