Mercurial > vim
diff src/testdir/test_popupwin.vim @ 16880:998603a243d7 v8.1.1441
patch 8.1.1441: popup window filter not yet implemented
commit https://github.com/vim/vim/commit/bf0eff0b724ebf4951f7ca82e6c648451f9f0c01
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 1 17:13:36 2019 +0200
patch 8.1.1441: popup window filter not yet implemented
Problem: Popup window filter not yet implemented.
Solution: Implement the popup filter.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 01 Jun 2019 17:15:06 +0200 |
parents | 4096722cd9c1 |
children | 59e4148c0c73 |
line wrap: on
line diff
--- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -473,3 +473,46 @@ func Test_popup_atcursor() bwipe! endfunc + +func Test_popup_filter() + new + call setline(1, 'some text') + + func MyPopupFilter(winid, c) + if a:c == 'e' + let g:eaten = 'e' + return 1 + endif + if a:c == '0' + let g:ignored = '0' + return 0 + endif + if a:c == 'x' + call popup_close(a:winid) + return 1 + endif + return 0 + endfunc + + let winid = popup_create('something', {'filter': 'MyPopupFilter'}) + redraw + + " e is consumed by the filter + call feedkeys('e', 'xt') + call assert_equal('e', g:eaten) + + " 0 is ignored by the filter + normal $ + call assert_equal(9, getcurpos()[2]) + call feedkeys('0', 'xt') + call assert_equal('0', g:ignored) + call assert_equal(1, getcurpos()[2]) + + " x closes the popup + call feedkeys('x', 'xt') + call assert_equal('e', g:eaten) + call assert_equal(-1, winbufnr(winid)) + + delfunc MyPopupFilter + popupclear +endfunc