comparison src/testdir/test_syntax.vim @ 20725:f4455c71a8aa v8.2.0915

patch 8.2.0915: search() cannot skip over matches like searchpair() can Commit: https://github.com/vim/vim/commit/adc17a5f9d207fd1623fd923457a46efc9214777 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 6 18:37:51 2020 +0200 patch 8.2.0915: search() cannot skip over matches like searchpair() can Problem: Search() cannot skip over matches like searchpair() can. Solution: Add an optional "skip" argument. (Christian Brabandt, closes https://github.com/vim/vim/issues/861)
author Bram Moolenaar <Bram@vim.org>
date Sat, 06 Jun 2020 18:45:03 +0200
parents 116c7bd5e980
children 6a4806e326dd
comparison
equal deleted inserted replaced
20724:b4f459787045 20725:f4455c71a8aa
770 call assert_equal([11,11,-1,-1], a) " over-attached 'else' visible 770 call assert_equal([11,11,-1,-1], a) " over-attached 'else' visible
771 771
772 quit! 772 quit!
773 endfunc 773 endfunc
774 774
775 func Test_search_syntax_skip()
776 new
777 let lines =<< trim END
778
779 /* This is VIM */
780 Another Text for VIM
781 let a = "VIM"
782 END
783 call setline(1, lines)
784 syntax on
785 syntax match Comment "^/\*.*\*/"
786 syntax match String '".*"'
787
788 " Skip argument using string evaluation.
789 1
790 call search('VIM', 'w', '', 0, 'synIDattr(synID(line("."), col("."), 1), "name") =~? "comment"')
791 call assert_equal('Another Text for VIM', getline('.'))
792 1
793 call search('VIM', 'w', '', 0, 'synIDattr(synID(line("."), col("."), 1), "name") !~? "string"')
794 call assert_equal(' let a = "VIM"', getline('.'))
795
796 " Skip argument using Lambda.
797 1
798 call search('VIM', 'w', '', 0, { -> synIDattr(synID(line("."), col("."), 1), "name") =~? "comment"})
799 call assert_equal('Another Text for VIM', getline('.'))
800
801 1
802 call search('VIM', 'w', '', 0, { -> synIDattr(synID(line("."), col("."), 1), "name") !~? "string"})
803 call assert_equal(' let a = "VIM"', getline('.'))
804
805 " Skip argument using funcref.
806 func InComment()
807 return synIDattr(synID(line("."), col("."), 1), "name") =~? "comment"
808 endfunc
809 func InString()
810 return synIDattr(synID(line("."), col("."), 1), "name") !~? "string"
811 endfunc
812 1
813 call search('VIM', 'w', '', 0, function('InComment'))
814 call assert_equal('Another Text for VIM', getline('.'))
815
816 1
817 call search('VIM', 'w', '', 0, function('InString'))
818 call assert_equal(' let a = "VIM"', getline('.'))
819
820 delfunc InComment
821 delfunc InString
822 bwipe!
823 endfunc
824
775 " vim: shiftwidth=2 sts=2 expandtab 825 " vim: shiftwidth=2 sts=2 expandtab