comparison src/testdir/test_normal.vim @ 31821:5614e76f3dee v9.0.1243

patch 9.0.1243: :setglobal cannot use script-local function for "expr" option Commit: https://github.com/vim/vim/commit/01d4efe2e87632aa085897d3d64e27585908f977 Author: zeertzjq <zeertzjq@outlook.com> Date: Wed Jan 25 15:31:28 2023 +0000 patch 9.0.1243: :setglobal cannot use script-local function for "expr" option Problem: :setglobal cannot use script-local function for "expr" option. Solution: Use the pointer to the option value properly. (closes https://github.com/vim/vim/issues/11883)
author Bram Moolenaar <Bram@vim.org>
date Wed, 25 Jan 2023 16:45:03 +0100
parents 79a60c5b18cc
children dbec60b8c253
comparison
equal deleted inserted replaced
31820:08ee50169c0f 31821:5614e76f3dee
260 func! s:Format() 260 func! s:Format()
261 let g:FormatArgs = [v:lnum, v:count] 261 let g:FormatArgs = [v:lnum, v:count]
262 endfunc 262 endfunc
263 set formatexpr=s:Format() 263 set formatexpr=s:Format()
264 call assert_equal(expand('<SID>') .. 'Format()', &formatexpr) 264 call assert_equal(expand('<SID>') .. 'Format()', &formatexpr)
265 call assert_equal(expand('<SID>') .. 'Format()', &g:formatexpr)
265 new | only 266 new | only
266 call setline(1, range(1, 40)) 267 call setline(1, range(1, 40))
267 let g:FormatArgs = [] 268 let g:FormatArgs = []
268 normal! 2GVjgq 269 normal! 2GVjgq
269 call assert_equal([2, 2], g:FormatArgs) 270 call assert_equal([2, 2], g:FormatArgs)
270 bw! 271 bw!
271 set formatexpr=<SID>Format() 272 set formatexpr=<SID>Format()
272 call assert_equal(expand('<SID>') .. 'Format()', &formatexpr) 273 call assert_equal(expand('<SID>') .. 'Format()', &formatexpr)
274 call assert_equal(expand('<SID>') .. 'Format()', &g:formatexpr)
273 new | only 275 new | only
274 call setline(1, range(1, 40)) 276 call setline(1, range(1, 40))
275 let g:FormatArgs = [] 277 let g:FormatArgs = []
276 normal! 4GVjgq 278 normal! 4GVjgq
277 call assert_equal([4, 2], g:FormatArgs) 279 call assert_equal([4, 2], g:FormatArgs)
278 bw! 280 bw!
279 let &formatexpr = 's:Format()' 281 let &formatexpr = 's:Format()'
282 call assert_equal(expand('<SID>') .. 'Format()', &g:formatexpr)
280 new | only 283 new | only
281 call setline(1, range(1, 40)) 284 call setline(1, range(1, 40))
282 let g:FormatArgs = [] 285 let g:FormatArgs = []
283 normal! 6GVjgq 286 normal! 6GVjgq
284 call assert_equal([6, 2], g:FormatArgs) 287 call assert_equal([6, 2], g:FormatArgs)
285 bw! 288 bw!
286 let &formatexpr = '<SID>Format()' 289 let &formatexpr = '<SID>Format()'
290 call assert_equal(expand('<SID>') .. 'Format()', &g:formatexpr)
287 new | only 291 new | only
288 call setline(1, range(1, 40)) 292 call setline(1, range(1, 40))
289 let g:FormatArgs = [] 293 let g:FormatArgs = []
290 normal! 8GVjgq 294 normal! 8GVjgq
291 call assert_equal([8, 2], g:FormatArgs) 295 call assert_equal([8, 2], g:FormatArgs)
296 bw!
292 setlocal formatexpr= 297 setlocal formatexpr=
298 setglobal formatexpr=s:Format()
299 call assert_equal(expand('<SID>') .. 'Format()', &g:formatexpr)
300 call assert_equal('', &formatexpr)
301 new
302 call assert_equal(expand('<SID>') .. 'Format()', &formatexpr)
303 call setline(1, range(1, 40))
304 let g:FormatArgs = []
305 normal! 10GVjgq
306 call assert_equal([10, 2], g:FormatArgs)
307 bw!
308 setglobal formatexpr=<SID>Format()
309 call assert_equal(expand('<SID>') .. 'Format()', &g:formatexpr)
310 call assert_equal('', &formatexpr)
311 new
312 call assert_equal(expand('<SID>') .. 'Format()', &formatexpr)
313 call setline(1, range(1, 40))
314 let g:FormatArgs = []
315 normal! 12GVjgq
316 call assert_equal([12, 2], g:FormatArgs)
317 bw!
318 let &g:formatexpr = 's:Format()'
319 call assert_equal(expand('<SID>') .. 'Format()', &g:formatexpr)
320 call assert_equal('', &formatexpr)
321 new
322 call assert_equal(expand('<SID>') .. 'Format()', &formatexpr)
323 call setline(1, range(1, 40))
324 let g:FormatArgs = []
325 normal! 14GVjgq
326 call assert_equal([14, 2], g:FormatArgs)
327 bw!
328 let &g:formatexpr = '<SID>Format()'
329 call assert_equal(expand('<SID>') .. 'Format()', &g:formatexpr)
330 call assert_equal('', &formatexpr)
331 new
332 call assert_equal(expand('<SID>') .. 'Format()', &formatexpr)
333 call setline(1, range(1, 40))
334 let g:FormatArgs = []
335 normal! 16GVjgq
336 call assert_equal([16, 2], g:FormatArgs)
337 bw!
338 set formatexpr=
293 delfunc s:Format 339 delfunc s:Format
294 bw! 340 bw!
295 endfunc 341 endfunc
296 342
297 " basic test for formatprg 343 " basic test for formatprg