patch 8.2.1985: crash when closing terminal popup with <Cmd> mapping
Problem: Crash when closing terminal popup with <Cmd> mapping.
Solution: Check b_term is not NULL. (closes #7294)
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index 137a8a6..8d68ceb 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -1225,6 +1225,18 @@
call delete('Xopenterm')
endfunc
+func Test_terminal_popup_with_cmd()
+ " this was crashing
+ let buf = term_start(&shell, #{hidden: v:true})
+ let s:winid = popup_create(buf, {})
+ tnoremap <F3> <Cmd>call popup_close(s:winid)<CR>
+ call feedkeys("\<F3>", 'xt')
+
+ tunmap <F3>
+ exe 'bwipe! ' .. buf
+ unlet s:winid
+endfunc
+
func Check_dump01(off)
call assert_equal('one two three four five', trim(getline(a:off + 1)))
call assert_equal('~ Select Word', trim(getline(a:off + 7)))