mirror of
https://github.com/vim/vim.git
synced 2025-10-17 07:34:11 -04:00
patch 8.1.1575: callbacks may be garbage collected
Problem: Callbacks may be garbage collected. Solution: Set reference in callbacks. (Ozaki Kiichi, closes #4564)
This commit is contained in:
@@ -102,3 +102,24 @@ func Test_prompt_editing()
|
||||
call StopVimInTerminal(buf)
|
||||
call delete(scriptName)
|
||||
endfunc
|
||||
|
||||
func Test_prompt_garbage_collect()
|
||||
func MyPromptCallback(x, text)
|
||||
" NOP
|
||||
endfunc
|
||||
func MyPromptInterrupt(x)
|
||||
" NOP
|
||||
endfunc
|
||||
|
||||
new
|
||||
set buftype=prompt
|
||||
call prompt_setcallback(bufnr(''), function('MyPromptCallback', [{}]))
|
||||
call prompt_setinterrupt(bufnr(''), function('MyPromptInterrupt', [{}]))
|
||||
call test_garbagecollect_now()
|
||||
" Must not crash
|
||||
call feedkeys("\<CR>\<C-C>", 'xt')
|
||||
call assert_true(v:true)
|
||||
|
||||
delfunc MyPromptCallback
|
||||
bwipe!
|
||||
endfunc
|
||||
|
Reference in New Issue
Block a user