patch 8.2.1636: get stuck if a popup filter causes an error
Problem: Get stuck if a popup filter causes an error.
Solution: Check whether the function can be called and does not cause an
error. (closes #6902)
diff --git a/src/testdir/dumps/Test_popupwin_three_errors_1.dump b/src/testdir/dumps/Test_popupwin_three_errors_1.dump
new file mode 100644
index 0000000..2bf9a54
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_three_errors_1.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @27|o+0#0000001#ffd7ff255|n|e| |t|w|o| |t|h|r|e@1|.@2| +0#4040ff13#ffffff0@29
+|~| @73
+|~| @73
+|~| @73
+|E+0#ffffff16#e000002|8|9|6|:| |A|r|g|u|m|e|n|t| |o|f| |f|i|l|t|e|r|(|)| |m|u|s|t| |b|e| |a| |L|i|s|t|,| |D|i|c|t|i|o|n|a|r|y| |o|r| |B|l|o|b| +0#0000000#ffffff0@13
+@57|0|,|0|-|1| @8|A|l@1|
diff --git a/src/testdir/dumps/Test_popupwin_three_errors_2.dump b/src/testdir/dumps/Test_popupwin_three_errors_2.dump
new file mode 100644
index 0000000..09550a2
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_three_errors_2.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|E+0#ffffff16#e000002|8|9|6|:| |A|r|g|u|m|e|n|t| |o|f| |f|i|l|t|e|r|(|)| |m|u|s|t| |b|e| |a| |L|i|s|t|,| |D|i|c|t|i|o|n|a|r|y| |o|r| |B|l|o|b| +0#0000000#ffffff0@13
+@57|0|,|0|-|1| @8|A|l@1|
diff --git a/src/testdir/dumps/Test_popupwin_wrong_name.dump b/src/testdir/dumps/Test_popupwin_wrong_name.dump
new file mode 100644
index 0000000..e63ced5
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_wrong_name.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|E+0#ffffff16#e000002|1@1|7|:| |U|n|k|n|o|w|n| |f|u|n|c|t|i|o|n|:| |N|o|S|u|c|h|F|u|n|c| +0#0000000#ffffff0@22|0|,|0|-|1| @8|A|l@1|
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index a92dc25..954086c 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -3516,7 +3516,44 @@
call VerifyScreenDump(buf, 'Test_popupwin_ctrl_c', {})
call StopVimInTerminal(buf)
- call delete('XtestPopupCorners')
+ call delete('XtestPopupCtrlC')
+endfunc
+
+func Test_popupwin_filter_close_wrong_name()
+ CheckScreendump
+
+ let lines =<< trim END
+ call popup_create('one two three...', {'filter': 'NoSuchFunc'})
+ END
+ call writefile(lines, 'XtestPopupWrongName')
+
+ let buf = RunVimInTerminal('-S XtestPopupWrongName', #{rows: 10})
+
+ call term_sendkeys(buf, "j")
+ call VerifyScreenDump(buf, 'Test_popupwin_wrong_name', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XtestPopupWrongName')
+endfunc
+
+func Test_popupwin_filter_close_three_errors()
+ CheckScreendump
+
+ let lines =<< trim END
+ set cmdheight=2
+ call popup_create('one two three...', {'filter': 'filter'})
+ END
+ call writefile(lines, 'XtestPopupThreeErrors')
+
+ let buf = RunVimInTerminal('-S XtestPopupThreeErrors', #{rows: 10})
+
+ call term_sendkeys(buf, "jj")
+ call VerifyScreenDump(buf, 'Test_popupwin_three_errors_1', {})
+ call term_sendkeys(buf, "j")
+ call VerifyScreenDump(buf, 'Test_popupwin_three_errors_2', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XtestPopupThreeErrors')
endfunc
func Test_popupwin_atcursor_far_right()