diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-06-06 18:37:51 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-06-06 18:37:51 +0200 |
commit | adc17a5f9d207fd1623fd923457a46efc9214777 (patch) | |
tree | 9c80498c748b98ef43576c925ee9646a78cecb53 /src/testdir/test_syntax.vim | |
parent | d8df304c59040ef6689a1e4af1dac27ce566909e (diff) |
patch 8.2.0915: search() cannot skip over matches like searchpair() canv8.2.0915
Problem: Search() cannot skip over matches like searchpair() can.
Solution: Add an optional "skip" argument. (Christian Brabandt, closes #861)
Diffstat (limited to 'src/testdir/test_syntax.vim')
-rw-r--r-- | src/testdir/test_syntax.vim | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim index 20f2318b44..ee9406b3c7 100644 --- a/src/testdir/test_syntax.vim +++ b/src/testdir/test_syntax.vim @@ -772,4 +772,54 @@ func Test_syntax_foldlevel() quit! endfunc +func Test_search_syntax_skip() + new + let lines =<< trim END + + /* This is VIM */ + Another Text for VIM + let a = "VIM" + END + call setline(1, lines) + syntax on + syntax match Comment "^/\*.*\*/" + syntax match String '".*"' + + " Skip argument using string evaluation. + 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 assert_equal(' let a = "VIM"', getline('.')) + + " Skip argument using Lambda. + 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 assert_equal(' let a = "VIM"', getline('.')) + + " Skip argument using funcref. + func InComment() + return synIDattr(synID(line("."), col("."), 1), "name") =~? "comment" + endfunc + func InString() + 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 assert_equal(' let a = "VIM"', getline('.')) + + delfunc InComment + delfunc InString + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab |