comparison src/testdir/test_vim9_script.vim @ 25469:dcd45fe7fe2e v8.2.3271

patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function Commit: https://github.com/vim/vim/commit/e4db17fb6e2d029aa2dddfca703ace9bcf0d85fd Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 1 21:19:43 2021 +0200 patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function Problem: Vim9: cannot use :command or :au with a block in a :def function. Solution: Recognize the start of the block.
author Bram Moolenaar <Bram@vim.org>
date Sun, 01 Aug 2021 21:30:03 +0200
parents effe5f2b4d01
children 911fdca7f736
comparison
equal deleted inserted replaced
25468:0290badbbf7b 25469:dcd45fe7fe2e
330 # function is compiled here, after blocks have finished, can still access 330 # function is compiled here, after blocks have finished, can still access
331 # "foo" and "bar" 331 # "foo" and "bar"
332 assert_equal(['foo', 'bar'], Func()) 332 assert_equal(['foo', 'bar'], Func())
333 END 333 END
334 CheckScriptSuccess(lines) 334 CheckScriptSuccess(lines)
335 enddef
336
337 " legacy func for command that's defined later
338 func InvokeSomeCommand()
339 SomeCommand
340 endfunc
341
342 def Test_autocommand_block()
343 com SomeCommand {
344 g:someVar = 'some'
345 }
346 InvokeSomeCommand()
347 assert_equal('some', g:someVar)
348
349 delcommand SomeCommand
350 unlet g:someVar
351 enddef
352
353 def Test_command_block()
354 au BufNew *.xml {
355 g:otherVar = 'other'
356 }
357 split other.xml
358 assert_equal('other', g:otherVar)
359
360 bwipe!
361 au! BufNew *.xml
362 unlet g:otherVar
335 enddef 363 enddef
336 364
337 func g:NoSuchFunc() 365 func g:NoSuchFunc()
338 echo 'none' 366 echo 'none'
339 endfunc 367 endfunc