mirror of
https://github.com/neovim/neovim.git
synced 2026-02-04 11:30:53 +10:00
vim-patch:9.0.0406: deferred functions not invoked when partial func exits
Problem: Deferred functions not invoked when partial func exits.
Solution: Create a funccall_T when calling a :def function.
9667b2c888
The remove_funccal() function is currently unused, but it will be used
in patch 9.0.0618.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -633,5 +633,34 @@ func Test_defer_quitall()
|
||||
call assert_false(filereadable('XQuitallTwo'))
|
||||
endfunc
|
||||
|
||||
func Test_defer_quitall_in_expr_func()
|
||||
throw 'Skipped: Vim9 script is N/A'
|
||||
let lines =<< trim END
|
||||
def DefIndex(idx: number, val: string): bool
|
||||
call writefile([idx .. ': ' .. val], 'Xentry' .. idx, 'D')
|
||||
if val == 'b'
|
||||
qa!
|
||||
endif
|
||||
return val == 'c'
|
||||
enddef
|
||||
|
||||
def Test_defer_in_funcref()
|
||||
assert_equal(2, indexof(['a', 'b', 'c'], funcref('g:DefIndex')))
|
||||
enddef
|
||||
call Test_defer_in_funcref()
|
||||
END
|
||||
call writefile(lines, 'XdeferQuitallExpr', 'D')
|
||||
let res = system(GetVimCommandClean() .. ' -X -S XdeferQuitallExpr')
|
||||
call assert_equal(0, v:shell_error)
|
||||
call assert_false(filereadable('Xentry0'))
|
||||
call assert_false(filereadable('Xentry1'))
|
||||
call assert_false(filereadable('Xentry2'))
|
||||
endfunc
|
||||
|
||||
func FuncIndex(idx, val)
|
||||
call writefile([a:idx .. ': ' .. a:val], 'Xentry' .. a:idx, 'D')
|
||||
return a:val == 'c'
|
||||
endfunc
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
Reference in New Issue
Block a user