patch 8.1.1920: cannot always close a popup when filter consumes all events
Problem: Cannot close a popup by the X when a filter consumes all events.
Solution: Check for a click on the close button before invoking filters.
(closes #4858)
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index abae5db..9471857 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -420,6 +420,15 @@
call feedkeys("\<F4>\<LeftMouse>\<LeftRelease>", "xt")
endfunc
map <silent> <F4> :call test_setmouse(3, 17)<CR>
+ func CreateWithMenuFilter()
+ let winid = popup_create('barfoo', #{
+ \ close: 'button',
+ \ filter: 'popup_filter_menu',
+ \ border: [],
+ \ line: 1,
+ \ col: 40,
+ \ })
+ endfunc
END
call writefile(lines, 'XtestPopupClose')
let buf = RunVimInTerminal('-S XtestPopupClose', #{rows: 10})
@@ -431,6 +440,14 @@
call term_sendkeys(buf, ":call CloseWithClick()\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_close_03', {})
+ call term_sendkeys(buf, ":call CreateWithMenuFilter()\<CR>")
+ call VerifyScreenDump(buf, 'Test_popupwin_close_04', {})
+
+ " We have to send the actual mouse code, feedkeys() would be caught the
+ " filter.
+ call term_sendkeys(buf, "\<Esc>[<0;47;1M")
+ call VerifyScreenDump(buf, 'Test_popupwin_close_05', {})
+
" clean up
call StopVimInTerminal(buf)
call delete('XtestPopupClose')