Skip to content

Commit 180246c

Browse files
zeertzjqbrammool
authored andcommitted
patch 8.2.5152: search() gets stuck with "c" and skip evaluates to true
Problem: search() gets stuck with "c" and skip evaluates to true. Solution: Reset the SEARCH_START option. (closes #10608)
1 parent 8eba2bd commit 180246c

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/evalfunc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8543,6 +8543,9 @@ search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
85438543
if (!do_skip)
85448544
break;
85458545
}
8546+
8547+
// clear the start flag to avoid getting stuck here
8548+
options &= ~SEARCH_START;
85468549
}
85478550

85488551
if (subpatnum != FAIL)

src/testdir/test_syntax.vim

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,9 @@ func Test_search_syntax_skip()
838838
1
839839
call search('VIM', 'w', '', 0, 'synIDattr(synID(line("."), col("."), 1), "name") =~? "comment"')
840840
call assert_equal('Another Text for VIM', getline('.'))
841+
841842
1
842-
call search('VIM', 'w', '', 0, 'synIDattr(synID(line("."), col("."), 1), "name") !~? "string"')
843+
call search('VIM', 'cw', '', 0, 'synIDattr(synID(line("."), col("."), 1), "name") !~? "string"')
843844
call assert_equal(' let a = "VIM"', getline('.'))
844845

845846
" Skip argument using Lambda.
@@ -848,26 +849,27 @@ func Test_search_syntax_skip()
848849
call assert_equal('Another Text for VIM', getline('.'))
849850

850851
1
851-
call search('VIM', 'w', '', 0, { -> synIDattr(synID(line("."), col("."), 1), "name") !~? "string"})
852+
call search('VIM', 'cw', '', 0, { -> synIDattr(synID(line("."), col("."), 1), "name") !~? "string"})
852853
call assert_equal(' let a = "VIM"', getline('.'))
853854

854855
" Skip argument using funcref.
855856
func InComment()
856857
return synIDattr(synID(line("."), col("."), 1), "name") =~? "comment"
857858
endfunc
858-
func InString()
859+
func NotInString()
859860
return synIDattr(synID(line("."), col("."), 1), "name") !~? "string"
860861
endfunc
862+
861863
1
862864
call search('VIM', 'w', '', 0, function('InComment'))
863865
call assert_equal('Another Text for VIM', getline('.'))
864866

865867
1
866-
call search('VIM', 'w', '', 0, function('InString'))
868+
call search('VIM', 'cw', '', 0, function('NotInString'))
867869
call assert_equal(' let a = "VIM"', getline('.'))
868870

869871
delfunc InComment
870-
delfunc InString
872+
delfunc NotInString
871873
bwipe!
872874
endfunc
873875

src/version.c

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

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
5152,
737739
/**/
738740
5151,
739741
/**/

0 commit comments

Comments
 (0)