Mercurial > vim
comparison src/testdir/test_tagfunc.vim @ 26268:3aa48d4e3dc8 v8.2.3665
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Commit: https://github.com/vim/vim/commit/19916a8c8920b6a1fd737ffa6d4e363fc7a96319
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Wed Nov 24 16:32:55 2021 +0000
patch 8.2.3665: cannot use a lambda for 'tagfunc'
Problem: Cannot use a lambda for 'tagfunc'.
Solution: Use 'tagfunc' like 'opfunc'. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/9204)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 24 Nov 2021 17:45:03 +0100 |
parents | 4902263c302e |
children | dbe615b75f15 |
comparison
equal
deleted
inserted
replaced
26267:069672443852 | 26268:3aa48d4e3dc8 |
---|---|
115 set tagfunc& | 115 set tagfunc& |
116 delfunc Mytagfunc1 | 116 delfunc Mytagfunc1 |
117 delfunc Mytagfunc2 | 117 delfunc Mytagfunc2 |
118 endfunc | 118 endfunc |
119 | 119 |
120 " Test for different ways of setting the 'tagfunc' option | |
121 func Test_tagfunc_callback() | |
122 " Test for using a function() | |
123 func MytagFunc1(pat, flags, info) | |
124 let g:MytagFunc1_args = [a:pat, a:flags, a:info] | |
125 return v:null | |
126 endfunc | |
127 let g:MytagFunc1_args = [] | |
128 set tagfunc=function('MytagFunc1') | |
129 call assert_fails('tag abc', 'E433:') | |
130 call assert_equal(['abc', '', {}], g:MytagFunc1_args) | |
131 | |
132 " Test for using a funcref() | |
133 new | |
134 func MytagFunc2(pat, flags, info) | |
135 let g:MytagFunc2_args = [a:pat, a:flags, a:info] | |
136 return v:null | |
137 endfunc | |
138 let g:MytagFunc2_args = [] | |
139 set tagfunc=funcref('MytagFunc2') | |
140 call assert_fails('tag def', 'E433:') | |
141 call assert_equal(['def', '', {}], g:MytagFunc2_args) | |
142 | |
143 " Test for using a lambda function | |
144 new | |
145 func MytagFunc3(pat, flags, info) | |
146 let g:MytagFunc3_args = [a:pat, a:flags, a:info] | |
147 return v:null | |
148 endfunc | |
149 let g:MytagFunc3_args = [] | |
150 let &tagfunc= '{a, b, c -> MytagFunc3(a, b, c)}' | |
151 call assert_fails('tag ghi', 'E433:') | |
152 call assert_equal(['ghi', '', {}], g:MytagFunc3_args) | |
153 | |
154 " Test for clearing the 'tagfunc' option | |
155 set tagfunc='' | |
156 set tagfunc& | |
157 | |
158 call assert_fails("set tagfunc=function('abc')", "E700:") | |
159 call assert_fails("set tagfunc=funcref('abc')", "E700:") | |
160 let &tagfunc = "{a -> 'abc'}" | |
161 call assert_fails("echo taglist('a')", "E987:") | |
162 | |
163 " cleanup | |
164 delfunc MytagFunc1 | |
165 delfunc MytagFunc2 | |
166 delfunc MytagFunc3 | |
167 %bw! | |
168 endfunc | |
169 | |
120 " vim: shiftwidth=2 sts=2 expandtab | 170 " vim: shiftwidth=2 sts=2 expandtab |