aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_normal.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-02 20:47:52 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-12-02 21:28:07 +0800
commit7d1019442642d51f1af49bafa3b0450841129c2d (patch)
tree483704c6954e7d9694d0e06e7ec94a348293c421 /src/nvim/testdir/test_normal.vim
parent1aad5af637b0fc042e1155cc0955931e9ca75295 (diff)
downloadrneovim-7d1019442642d51f1af49bafa3b0450841129c2d.tar.gz
rneovim-7d1019442642d51f1af49bafa3b0450841129c2d.tar.bz2
rneovim-7d1019442642d51f1af49bafa3b0450841129c2d.zip
vim-patch:8.2.3838: cannot use script-local function for setting *func options
Problem: Cannot use script-local function for setting *func options. Solution: Use the script context. (Yegappan Lakshmanan, closes vim/vim#9362) https://github.com/vim/vim/commit/db1a410b610b2c1941311acc57dcc4afec20720e Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/testdir/test_normal.vim')
-rw-r--r--src/nvim/testdir/test_normal.vim35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim
index 83709420bf..d9b392992f 100644
--- a/src/nvim/testdir/test_normal.vim
+++ b/src/nvim/testdir/test_normal.vim
@@ -591,6 +591,21 @@ func Test_opfunc_callback()
END
call CheckTransLegacySuccess(lines)
+ " Test for using a script-local function name
+ func s:OpFunc3(type)
+ let g:OpFunc3Args = [a:type]
+ endfunc
+ set opfunc=s:OpFunc3
+ let g:OpFunc3Args = []
+ normal! g@l
+ call assert_equal(['char'], g:OpFunc3Args)
+
+ let &opfunc = 's:OpFunc3'
+ let g:OpFunc3Args = []
+ normal! g@l
+ call assert_equal(['char'], g:OpFunc3Args)
+ delfunc s:OpFunc3
+
" Using Vim9 lambda expression in legacy context should fail
" set opfunc=(a)\ =>\ OpFunc1(24,\ a)
let g:OpFunc1Args = []
@@ -614,14 +629,32 @@ func Test_opfunc_callback()
let lines =<< trim END
vim9script
- # Test for using a def function with opfunc
def g:Vim9opFunc(val: number, type: string): void
g:OpFunc1Args = [val, type]
enddef
+
+ # Test for using a def function with opfunc
set opfunc=function('g:Vim9opFunc',\ [60])
g:OpFunc1Args = []
normal! g@l
assert_equal([60, 'char'], g:OpFunc1Args)
+
+ # Test for using a global function name
+ &opfunc = g:OpFunc2
+ g:OpFunc2Args = []
+ normal! g@l
+ assert_equal(['char'], g:OpFunc2Args)
+ bw!
+
+ # Test for using a script-local function name
+ def s:LocalOpFunc(type: string): void
+ g:LocalOpFuncArgs = [type]
+ enddef
+ &opfunc = s:LocalOpFunc
+ g:LocalOpFuncArgs = []
+ normal! g@l
+ assert_equal(['char'], g:LocalOpFuncArgs)
+ bw!
END
" call CheckScriptSuccess(lines)