aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_normal.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-02 22:10:09 +0800
committerGitHub <noreply@github.com>2022-12-02 22:10:09 +0800
commit731432342058c1c4340fc3cc4782b5fcd4a756a0 (patch)
tree483704c6954e7d9694d0e06e7ec94a348293c421 /src/nvim/testdir/test_normal.vim
parenta3f01d32cba903b58e3ab5a353b4dba8c5431f9c (diff)
parent7d1019442642d51f1af49bafa3b0450841129c2d (diff)
downloadrneovim-731432342058c1c4340fc3cc4782b5fcd4a756a0.tar.gz
rneovim-731432342058c1c4340fc3cc4782b5fcd4a756a0.tar.bz2
rneovim-731432342058c1c4340fc3cc4782b5fcd4a756a0.zip
Merge pull request #21264 from zeertzjq/vim-8.2.3829
vim-patch:8.2.{3829,3838}: cannot use script-local function for setting *func options
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)