comparison src/testdir/test_mapping.vim @ 27457:4c16acb2525f v8.2.4257

patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent Commit: https://github.com/vim/vim/commit/62aec93bfdb9e1b40d03a6d2e8e9511f8b1bdb2d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 29 21:45:34 2022 +0000 patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent Problem: Vim9: finding global function without g: prefix but not finding global variable is inconsistent. Solution: Require using g: for a global function. Change the vim9.vim script into a Vim9 script with exports. Fix that import in legacy script does not work.
author Bram Moolenaar <Bram@vim.org>
date Sat, 29 Jan 2022 23:00:05 +0100
parents 959d6a664cfd
children ec52847967d8
comparison
equal deleted inserted replaced
27456:a8e2d91995ce 27457:4c16acb2525f
2 2
3 source shared.vim 3 source shared.vim
4 source check.vim 4 source check.vim
5 source screendump.vim 5 source screendump.vim
6 source term_util.vim 6 source term_util.vim
7 source vim9.vim 7 import './vim9.vim' as v9
8 8
9 func Test_abbreviation() 9 func Test_abbreviation()
10 " abbreviation with 0x80 should work 10 " abbreviation with 0x80 should work
11 inoreab чкпр vim 11 inoreab чкпр vim
12 call feedkeys("Goчкпр \<Esc>", "xt") 12 call feedkeys("Goчкпр \<Esc>", "xt")
1413 func Test_map_script_cmd_restore() 1413 func Test_map_script_cmd_restore()
1414 let lines =<< trim END 1414 let lines =<< trim END
1415 vim9script 1415 vim9script
1416 nnoremap <F3> <ScriptCmd>eval 1 + 2<CR> 1416 nnoremap <F3> <ScriptCmd>eval 1 + 2<CR>
1417 END 1417 END
1418 call CheckScriptSuccess(lines) 1418 call v9.CheckScriptSuccess(lines)
1419 call feedkeys("\<F3>:let g:result = 3+4\<CR>", 'xtc') 1419 call feedkeys("\<F3>:let g:result = 3+4\<CR>", 'xtc')
1420 call assert_equal(7, g:result) 1420 call assert_equal(7, g:result)
1421 1421
1422 nunmap <F3> 1422 nunmap <F3>
1423 unlet g:result 1423 unlet g:result
1429 onoremap <F3> <ScriptCmd>Func()<CR> 1429 onoremap <F3> <ScriptCmd>Func()<CR>
1430 def Func() 1430 def Func()
1431 g:func_called = 'yes' 1431 g:func_called = 'yes'
1432 enddef 1432 enddef
1433 END 1433 END
1434 call CheckScriptSuccess(lines) 1434 call v9.CheckScriptSuccess(lines)
1435 call feedkeys("y\<F3>\<Esc>", 'xtc') 1435 call feedkeys("y\<F3>\<Esc>", 'xtc')
1436 call assert_equal('yes', g:func_called) 1436 call assert_equal('yes', g:func_called)
1437 1437
1438 ounmap <F3> 1438 ounmap <F3>
1439 unlet g:func_called 1439 unlet g:func_called
1447 autocmd CmdlineEnter * silent! nunmap <F4> 1447 autocmd CmdlineEnter * silent! nunmap <F4>
1448 nnoremap <F3> :<ScriptCmd>eval setbufvar(bufnr(), "result", n)<CR> 1448 nnoremap <F3> :<ScriptCmd>eval setbufvar(bufnr(), "result", n)<CR>
1449 feedkeys("\<F3>\<CR>", 'xct') 1449 feedkeys("\<F3>\<CR>", 'xct')
1450 assert_equal(123, b:result) 1450 assert_equal(123, b:result)
1451 END 1451 END
1452 call CheckScriptSuccess(lines) 1452 call v9.CheckScriptSuccess(lines)
1453 1453
1454 nunmap <F3> 1454 nunmap <F3>
1455 unlet b:result 1455 unlet b:result
1456 autocmd! CmdlineEnter 1456 autocmd! CmdlineEnter
1457 endfunc 1457 endfunc