aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-06-23 19:34:43 +0800
committerGitHub <noreply@github.com>2022-06-23 19:34:43 +0800
commit84de4d86553bd47ea8312b2fcc3c2bea9128611c (patch)
treea471c43b8dcd75c02db508366656e53492b822ae
parenta3ce03bef1d54d67ad5dff4b35691e7f9b31cafa (diff)
downloadrneovim-84de4d86553bd47ea8312b2fcc3c2bea9128611c.tar.gz
rneovim-84de4d86553bd47ea8312b2fcc3c2bea9128611c.tar.bz2
rneovim-84de4d86553bd47ea8312b2fcc3c2bea9128611c.zip
vim-patch:8.2.5152: search() gets stuck with "c" and skip evaluates to true (#19064)
Problem: search() gets stuck with "c" and skip evaluates to true. Solution: Reset the SEARCH_START option. (closes vim/vim#10608) https://github.com/vim/vim/commit/180246cfd1a5842c538fa8a4a0b520f1d95c90c7
-rw-r--r--src/nvim/eval/funcs.c3
-rw-r--r--src/nvim/testdir/test_syntax.vim12
2 files changed, 10 insertions, 5 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 56468190b5..8e49d1b9a8 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -7766,6 +7766,9 @@ static int search_cmn(typval_T *argvars, pos_T *match_pos, int *flagsp)
break;
}
}
+
+ // clear the start flag to avoid getting stuck here
+ options &= ~SEARCH_START;
}
if (subpatnum != FAIL) {
diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim
index c46bba04e3..9f50b3c241 100644
--- a/src/nvim/testdir/test_syntax.vim
+++ b/src/nvim/testdir/test_syntax.vim
@@ -745,8 +745,9 @@ func Test_search_syntax_skip()
1
call search('VIM', 'w', '', 0, 'synIDattr(synID(line("."), col("."), 1), "name") =~? "comment"')
call assert_equal('Another Text for VIM', getline('.'))
+
1
- call search('VIM', 'w', '', 0, 'synIDattr(synID(line("."), col("."), 1), "name") !~? "string"')
+ call search('VIM', 'cw', '', 0, 'synIDattr(synID(line("."), col("."), 1), "name") !~? "string"')
call assert_equal(' let a = "VIM"', getline('.'))
" Skip argument using Lambda.
@@ -755,26 +756,27 @@ func Test_search_syntax_skip()
call assert_equal('Another Text for VIM', getline('.'))
1
- call search('VIM', 'w', '', 0, { -> synIDattr(synID(line("."), col("."), 1), "name") !~? "string"})
+ call search('VIM', 'cw', '', 0, { -> synIDattr(synID(line("."), col("."), 1), "name") !~? "string"})
call assert_equal(' let a = "VIM"', getline('.'))
" Skip argument using funcref.
func InComment()
return synIDattr(synID(line("."), col("."), 1), "name") =~? "comment"
endfunc
- func InString()
+ func NotInString()
return synIDattr(synID(line("."), col("."), 1), "name") !~? "string"
endfunc
+
1
call search('VIM', 'w', '', 0, function('InComment'))
call assert_equal('Another Text for VIM', getline('.'))
1
- call search('VIM', 'w', '', 0, function('InString'))
+ call search('VIM', 'cw', '', 0, function('NotInString'))
call assert_equal(' let a = "VIM"', getline('.'))
delfunc InComment
- delfunc InString
+ delfunc NotInString
bwipe!
endfunc