To: vim_dev@googlegroups.com Subject: Patch 8.2.1769 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1769 Problem: A popup filter interferes with using :normal to move the cursor in a popup. Solution: Do not invoke the filter when ex_normal_busy is set. Files: runtime/doc/popup.txt, src/getchar.c, src/evalfunc.c, src/ex_docmd.c, src/menu.c, src/globals.h, src/testdir/test_popupwin.vim, src/testdir/dumps/Test_popupwin_normal_cmd.dump *** ../vim-8.2.1768/runtime/doc/popup.txt 2020-05-18 19:46:00.070602956 +0200 --- runtime/doc/popup.txt 2020-09-28 22:26:46.562308885 +0200 *************** *** 908,918 **** --- 910,931 ---- Vim provides standard filters |popup_filter_menu()| and |popup_filter_yesno()|. + Keys coming from a `:normal` command do not pass through the filter. This can + be used to move the cursor in a popup where the "cursorline" option is set: > + call win_execute(winid, 'normal! 10Gzz') + Keys coming from `feedkeys()` are passed through the filter. + Note that "x" is the normal way to close a popup. You may want to use Esc, but since many keys start with an Esc character, there may be a delay before Vim recognizes the Esc key. If you do use Esc, it is recommended to set the 'ttimeoutlen' option to 100 and set 'timeout' and/or 'ttimeout'. + *popup-filter-errors* + If the filter function can't be called, e.g. because the name is wrong, then + the popup is closed. If the filter causes an error then it is assumed to + return zero. If this happens three times in a row the popup is closed. If + the popup gives errors fewer than 10% of the calls then it won't be closed. + POPUP CALLBACK *popup-callback* *** ../vim-8.2.1768/src/getchar.c 2020-09-23 12:28:46.421898027 +0200 --- src/getchar.c 2020-09-28 22:16:11.712489576 +0200 *************** *** 1888,1894 **** } #endif #ifdef FEAT_PROP_POPUP ! if (!ex_normal_busy_done && popup_do_filter(c)) { if (c == Ctrl_C) got_int = FALSE; // avoid looping --- 1888,1896 ---- } #endif #ifdef FEAT_PROP_POPUP ! // Only filter keys that do not come from ":normal". Keys from feedkeys() ! // are filtered. ! if ((!ex_normal_busy || in_feedkeys) && popup_do_filter(c)) { if (c == Ctrl_C) got_int = FALSE; // avoid looping *************** *** 3168,3176 **** timedout = TRUE; continue; } - #ifdef FEAT_PROP_POPUP - ex_normal_busy_done = TRUE; - #endif // When 'insertmode' is set, ESC just beeps in Insert // mode. Use CTRL-L to make edit() return. --- 3170,3175 ---- *** ../vim-8.2.1768/src/evalfunc.c 2020-09-26 22:39:18.427725844 +0200 --- src/evalfunc.c 2020-09-28 22:15:20.084668419 +0200 *************** *** 2616,2630 **** msg_scroll = FALSE; if (!dangerous) ++ex_normal_busy; exec_normal(TRUE, lowlevel, TRUE); if (!dangerous) { --ex_normal_busy; ! #ifdef FEAT_PROP_POPUP ! if (ex_normal_busy == 0) ! ex_normal_busy_done = FALSE; ! #endif } msg_scroll |= save_msg_scroll; --- 2616,2630 ---- msg_scroll = FALSE; if (!dangerous) + { ++ex_normal_busy; + ++in_feedkeys; + } exec_normal(TRUE, lowlevel, TRUE); if (!dangerous) { --ex_normal_busy; ! --in_feedkeys; } msg_scroll |= save_msg_scroll; *** ../vim-8.2.1768/src/ex_docmd.c 2020-09-26 17:20:49.693186820 +0200 --- src/ex_docmd.c 2020-09-28 21:52:40.593408174 +0200 *************** *** 8037,8046 **** restore_current_state(&save_state); --ex_normal_busy; - #ifdef FEAT_PROP_POPUP - if (ex_normal_busy == 0) - ex_normal_busy_done = FALSE; - #endif setmouse(); #ifdef CURSOR_SHAPE ui_cursor_shape(); // may show different cursor shape --- 8037,8042 ---- *** ../vim-8.2.1768/src/menu.c 2020-09-23 12:28:46.421898027 +0200 --- src/menu.c 2020-09-28 21:53:01.453333531 +0200 *************** *** 2398,2407 **** menu->silent[idx]); restore_current_state(&save_state); --ex_normal_busy; - #ifdef FEAT_PROP_POPUP - if (ex_normal_busy == 0) - ex_normal_busy_done = FALSE; - #endif } else ins_typebuf(menu->strings[idx], menu->noremap[idx], 0, --- 2398,2403 ---- *** ../vim-8.2.1768/src/globals.h 2020-09-23 12:28:46.417898049 +0200 --- src/globals.h 2020-09-28 22:14:53.516760583 +0200 *************** *** 1150,1161 **** = {NULL, NULL, 0, 0, 0, 0, 0, 0, 0} #endif ; ! EXTERN int ex_normal_busy INIT(= 0); // recursiveness of ex_normal() ! EXTERN int ex_normal_lock INIT(= 0); // forbid use of ex_normal() ! #ifdef FEAT_PROP_POPUP ! // Set to TRUE when ex_normal_busy is set and out of typeahead. ! EXTERN int ex_normal_busy_done INIT(= FALSE); ! #endif #ifdef FEAT_EVAL EXTERN int ignore_script INIT(= FALSE); // ignore script input --- 1150,1158 ---- = {NULL, NULL, 0, 0, 0, 0, 0, 0, 0} #endif ; ! EXTERN int ex_normal_busy INIT(= 0); // recursiveness of ex_normal() ! EXTERN int in_feedkeys INIT(= 0); // ex_normal_busy set in feedkeys() ! EXTERN int ex_normal_lock INIT(= 0); // forbid use of ex_normal() #ifdef FEAT_EVAL EXTERN int ignore_script INIT(= FALSE); // ignore script input *** ../vim-8.2.1768/src/testdir/test_popupwin.vim 2020-09-27 22:47:01.884163380 +0200 --- src/testdir/test_popupwin.vim 2020-09-28 22:10:19.177719095 +0200 *************** *** 1539,1551 **** call popup_clear() endfunc ! " this tests that the "ex_normal_busy_done" flag works func Test_popup_filter_normal_cmd() CheckScreendump let lines =<< trim END ! let g:winid = popup_create('some text', {'filter': 'invalidfilter'}) ! call timer_start(0, {-> win_execute(g:winid, 'norm! zz')}) END call writefile(lines, 'XtestPopupNormal') let buf = RunVimInTerminal('-S XtestPopupNormal', #{rows: 10}) --- 1539,1552 ---- call popup_clear() endfunc ! " this tests that the filter is not used for :normal command func Test_popup_filter_normal_cmd() CheckScreendump let lines =<< trim END ! let text = range(1, 20)->map({_, v -> string(v)}) ! let g:winid = popup_create(text, #{maxheight: 5, minwidth: 3, filter: 'invalidfilter'}) ! call timer_start(0, {-> win_execute(g:winid, 'norm! 10Gzz')}) END call writefile(lines, 'XtestPopupNormal') let buf = RunVimInTerminal('-S XtestPopupNormal', #{rows: 10}) *** ../vim-8.2.1768/src/testdir/dumps/Test_popupwin_normal_cmd.dump 2020-09-23 12:28:46.429897985 +0200 --- src/testdir/dumps/Test_popupwin_normal_cmd.dump 2020-09-28 22:10:32.201673255 +0200 *************** *** 1,10 **** > +0&#ffffff0@74 |~+0#4040ff13&| @73 ! |~| @73 ! |~| @73 ! |~| @31| +0#0000000&@8| +0#4040ff13&@32 ! |~| @73 ! |~| @73 |~| @73 |~| @73 | +0#0000000&@56|0|,|0|-|1| @8|A|l@1| --- 1,10 ---- > +0&#ffffff0@74 |~+0#4040ff13&| @73 ! |~| @33|8+0#0000001#ffd7ff255| @1| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35 ! |~| @33|9+0#0000001#ffd7ff255| @1| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35 ! |~| @33|1+0#0000001#ffd7ff255|0| | +0#0000000#0000001| +0#4040ff13#ffffff0@35 ! |~| @33|1+0#0000001#ffd7ff255@1| | +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35 ! |~| @33|1+0#0000001#ffd7ff255|2| | +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@35 |~| @73 |~| @73 | +0#0000000&@56|0|,|0|-|1| @8|A|l@1| *** ../vim-8.2.1768/src/version.c 2020-09-28 21:41:08.616043789 +0200 --- src/version.c 2020-09-28 22:27:35.082143086 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1769, /**/ -- Me? A skeptic? I trust you have proof. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///