diff src/testdir/test_prompt_buffer.vim @ 17151:ebe9aab81898 v8.1.1575

patch 8.1.1575: callbacks may be garbage collected commit https://github.com/vim/vim/commit/75a1a9415b9c207de5a29b25c0d1949c6c9c5c61 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 20 03:45:36 2019 +0200 patch 8.1.1575: callbacks may be garbage collected Problem: Callbacks may be garbage collected. Solution: Set reference in callbacks. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/4564)
author Bram Moolenaar <Bram@vim.org>
date Thu, 20 Jun 2019 04:00:07 +0200
parents 8e9e9124c7a2
children 6d11a0d5751d
line wrap: on
line diff
--- a/src/testdir/test_prompt_buffer.vim
+++ b/src/testdir/test_prompt_buffer.vim
@@ -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