]> granicus.if.org Git - vim/commitdiff
patch 8.2.1769: popup filter interferes with using :normal to move the cursor v8.2.1769
authorBram Moolenaar <Bram@vim.org>
Mon, 28 Sep 2020 20:29:58 +0000 (22:29 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 28 Sep 2020 20:29:58 +0000 (22:29 +0200)
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.

runtime/doc/popup.txt
src/evalfunc.c
src/ex_docmd.c
src/getchar.c
src/globals.h
src/menu.c
src/testdir/dumps/Test_popupwin_normal_cmd.dump
src/testdir/test_popupwin.vim
src/version.c

index 118bc9b09ca19c4f891fbc5a5e8b38a3b531e0f4..0e28fdd335b56fd7debea5bcfa92126fd571c130 100644 (file)
@@ -1,4 +1,4 @@
-*popup.txt*  For Vim version 8.2.  Last change: 2020 Sep 27
+*popup.txt*  For Vim version 8.2.  Last change: 2020 Sep 28
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -910,6 +910,11 @@ A mouse click arrives as <LeftMouse>.  The coordinates can be obtained with
 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
index b387c8ccce4575f85b56519310cae70e483951bf..2af4bc00d6b6192cfce8326439ee5cca184dc5b2 100644 (file)
@@ -2616,15 +2616,15 @@ f_feedkeys(typval_T *argvars, typval_T *rettv UNUSED)
                msg_scroll = FALSE;
 
                if (!dangerous)
+               {
                    ++ex_normal_busy;
+                   ++in_feedkeys;
+               }
                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
+                   --in_feedkeys;
                }
 
                msg_scroll |= save_msg_scroll;
index bb504ffd6a8a6e8d75137f9897f9c8cfd255ab86..05378fdcd7a1daa3f1a4e5bb4e74091f72925726 100644 (file)
@@ -8037,10 +8037,6 @@ ex_normal(exarg_T *eap)
 
     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
index 2c7bd1fd2ef538f5a936af963d8927f3dd0e5a87..6e469f49b53eb016c941c6e2819ca436ac1f184f 100644 (file)
@@ -1888,7 +1888,9 @@ vgetc(void)
     }
 #endif
 #ifdef FEAT_PROP_POPUP
-    if (!ex_normal_busy_done && popup_do_filter(c))
+    // 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,9 +3170,6 @@ vgetorpeek(int advance)
                        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.
index eb33507d9feac9e208deab5cc30a4d3a94539896..4ca3092e9d7c18ee5fcd6c85a5ca23fe7a333dbe 100644 (file)
@@ -1150,12 +1150,9 @@ EXTERN typebuf_T typebuf         // typeahead buffer
                    = {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
+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
index f383ddde74554609e16491c4babb1ac370e60c0a..fd811de065556bb026e403c39ac1daa52dfba0c2 100644 (file)
@@ -2398,10 +2398,6 @@ execute_menu(exarg_T *eap, vimmenu_T *menu, int mode_idx)
                                                           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,
index f5548591c7e78ecc0b997b248ef42c9727ad629f..95588d6cff7a37798b6aebc48e4543d9a04ce38c 100644 (file)
@@ -1,10 +1,10 @@
 > +0&#ffffff0@74
 |~+0#4040ff13&| @73
-|~| @73
-|~| @73
-|~| @31| +0#0000000&@8| +0#4040ff13&@32
-|~| @73
-|~| @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| 
index ea2ee3b5ce4c3283254dbc03b9728b3374af3c51..e991fc116f25a9ba3f84ef73018a7aa37265f776 100644 (file)
@@ -1539,13 +1539,14 @@ func Test_popup_filter()
   call popup_clear()
 endfunc
 
-" this tests that the "ex_normal_busy_done" flag works
+" this tests that the filter is not used for :normal command
 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')})
+      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})
index 5d84e242d5e2557b4ba00595455391da3b8ba4e9..3d37c85bcf67f6e04a354220def0eeba834ad60c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1769,
 /**/
     1768,
 /**/