]> granicus.if.org Git - vim/commitdiff
patch 8.1.2110: CTRL-C closes two popups instead of one v8.1.2110
authorBram Moolenaar <Bram@vim.org>
Thu, 3 Oct 2019 20:35:52 +0000 (22:35 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 3 Oct 2019 20:35:52 +0000 (22:35 +0200)
Problem:    CTRL-C closes two popups instead of one.
Solution:   Reset got_int when the filter consumed the key.

src/getchar.c
src/testdir/test_popupwin.vim
src/version.c

index fcdc639688b36b265d3171b9d5f89f3d321f192e..5e098dfcf8b8d72c79510d3ad3335d2337f70f27 100644 (file)
@@ -1791,7 +1791,11 @@ vgetc(void)
 #endif
 #ifdef FEAT_TEXT_PROP
     if (popup_do_filter(c))
+    {
+       if (c == Ctrl_C)
+           got_int = FALSE;  // avoid looping
        c = K_IGNORE;
+    }
 #endif
 
     // Need to process the character before we know it's safe to do something
index 9d8a0d099bdaab71a8c789b894ff2833058836c1..771db9a69eec57f75937793b638d64e0fb4edaee 100644 (file)
@@ -2568,4 +2568,26 @@ func Test_popupwin_getoptions_tablocal()
   quit
 endfunc
 
+func Test_popupwin_cancel()
+  let win1 = popup_create('one', #{line: 5, filter: {... -> 0}})
+  let win2 = popup_create('two', #{line: 10, filter: {... -> 0}})
+  let win3 = popup_create('three', #{line: 15, filter: {... -> 0}})
+  call assert_equal(5, popup_getpos(win1).line)
+  call assert_equal(10, popup_getpos(win2).line)
+  call assert_equal(15, popup_getpos(win3).line)
+  " TODO: this also works without patch 8.1.2110
+  call feedkeys("\<C-C>", 'xt')
+  call assert_equal(5, popup_getpos(win1).line)
+  call assert_equal(10, popup_getpos(win2).line)
+  call assert_equal({}, popup_getpos(win3))
+  call feedkeys("\<C-C>", 'xt')
+  call assert_equal(5, popup_getpos(win1).line)
+  call assert_equal({}, popup_getpos(win2))
+  call assert_equal({}, popup_getpos(win3))
+  call feedkeys("\<C-C>", 'xt')
+  call assert_equal({}, popup_getpos(win1))
+  call assert_equal({}, popup_getpos(win2))
+  call assert_equal({}, popup_getpos(win3))
+endfunc
+
 " vim: shiftwidth=2 sts=2
index 00374c20e57ae2b59bb590e32bbde3632aceec52..ee1525d88906a0c0fb5e3497a13d46e9d4ec9c89 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2110,
 /**/
     2109,
 /**/