mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
vim-patch:9.0.1233: search() loops forever if "skip" is TRUE for all matches (#21956)
Problem: search() loops forever if "skip" is TRUE for all matches.
Solution: Keep the position of the first match.
3d79f0a430
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -6239,7 +6239,9 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
|
|||||||
// didn't find it or no skip argument
|
// didn't find it or no skip argument
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
firstpos = pos;
|
if (firstpos.lnum == 0) {
|
||||||
|
firstpos = pos;
|
||||||
|
}
|
||||||
|
|
||||||
// If the skip expression matches, ignore this match.
|
// If the skip expression matches, ignore this match.
|
||||||
{
|
{
|
||||||
|
@@ -1377,6 +1377,22 @@ func Test_subst_word_under_cursor()
|
|||||||
set noincsearch
|
set noincsearch
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_search_skip_all_matches()
|
||||||
|
enew
|
||||||
|
call setline(1, ['no match here',
|
||||||
|
\ 'match this line',
|
||||||
|
\ 'nope',
|
||||||
|
\ 'match in this line',
|
||||||
|
\ 'last line',
|
||||||
|
\ ])
|
||||||
|
call cursor(1, 1)
|
||||||
|
let lnum = search('this', '', 0, 0, 'getline(".") =~ "this line"')
|
||||||
|
" Only check that no match is found. Previously it searched forever.
|
||||||
|
call assert_equal(0, lnum)
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_search_undefined_behaviour()
|
func Test_search_undefined_behaviour()
|
||||||
CheckFeature terminal
|
CheckFeature terminal
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user