]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1230: inconsistent CTRL-C behaviour for popup windows v9.1.1230
authorglepnir <glephunter@gmail.com>
Fri, 21 Mar 2025 17:12:32 +0000 (18:12 +0100)
committerChristian Brabandt <cb@256bit.org>
Fri, 21 Mar 2025 17:12:32 +0000 (18:12 +0100)
Problem:  Ctrl-C closes popup windows that have a filter callback,
          but does not close popups without a filter callback.
Solution: Modified popup_do_filter() to also close popups without
          filter callback when Ctrl-C is pressed (glepnir).

fixes: #16839
closes: #16928

Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/pattern.txt
runtime/doc/version9.txt
src/popupwin.c
src/testdir/test_popupwin.vim
src/version.c

index 39eb5442b21c9e75fb109e06af8a29e632900507..f11040c4ec213e5829cafed56108b9dba097df6b 100644 (file)
@@ -1,4 +1,4 @@
-*pattern.txt*   For Vim version 9.1.  Last change: 2024 Dec 26
+*pattern.txt*   For Vim version 9.1.  Last change: 2025 Mar 21
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -141,6 +141,7 @@ CTRL-C                      Interrupt current (search) command.  Use CTRL-Break on
                        help users who use "vim file | grep word" and don't
                        know how to get out (blindly typing :qa<CR> would
                        work).
+                       If a popup is open, the active popup will be closed.
 
                                                        *:noh* *:nohlsearch*
 :noh[lsearch]          Stop the highlighting for the 'hlsearch' option.  It
index 6ecf64264d360d8b7c83ab6abb29da64346d1e87..377ab2ae00c3ac77a866bde7976a26c056f76e86 100644 (file)
@@ -1,4 +1,4 @@
-*version9.txt*  For Vim version 9.1.  Last change: 2025 Mar 19
+*version9.txt*  For Vim version 9.1.  Last change: 2025 Mar 21
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -41653,6 +41653,7 @@ Others: ~
 - add |dist#vim9#Launch()| and |dist#vim9#Open()| to the |vim-script-library|
   and decouple it from |netrw|
 - new digraph "APPROACHES THE LIMIT" using ".="
+- |CTRL-C| always closes the active |popup-window|.
 
                                                        *added-9.2*
 Added ~
index 2032492a9108351155ebbdea431bad34680c1655..76ebf38e5224b5b62dfa721692f0f539be478d70 100644 (file)
@@ -3586,6 +3586,20 @@ popup_do_filter(int c)
                && (wp->w_filter_mode & state) != 0)
            res = invoke_popup_filter(wp, c);
 
+    // when Ctrl-C and no popup has been processed (res is still FALSE)
+    // Try to find and close a popup that has no filter callback
+    if (c == Ctrl_C && res == FALSE)
+    {
+       popup_reset_handled(POPUP_HANDLED_2);
+       wp = find_next_popup(FALSE, POPUP_HANDLED_2);
+        if (wp != NULL)
+        {
+           popup_close_with_retval(wp, -1);
+           res = TRUE;
+       }
+    }
+
+
     if (must_redraw > was_must_redraw)
     {
        int save_got_int = got_int;
index e1041ef2006d1bf4fcb4164d1f8d4fd9c8b36e62..5082676ea2f3bfb757bc2498676e2af0cb93458c 100644 (file)
@@ -3898,6 +3898,24 @@ func Test_popupwin_cancel()
   call assert_equal({}, popup_getpos(win3))
 endfunc
 
+func Test_popupwin_cancel_with_without_filter()
+  let win1 = popup_create('with filter', #{line: 5, filter: {... -> 0}})
+  let win2 = popup_create('no filter', #{line: 10})
+
+  call assert_equal(5, popup_getpos(win1).line)
+  call assert_equal(10, popup_getpos(win2).line)
+
+  call feedkeys("\<C-C>", 'xt')
+  call assert_equal({}, popup_getpos(win1))
+  call assert_equal(10, popup_getpos(win2).line)
+
+  call feedkeys("\<C-C>", 'xt')
+  call assert_equal({}, popup_getpos(win1))
+  call assert_equal({}, popup_getpos(win2))
+
+  call popup_clear()
+endfunc
+
 func Test_popupwin_filter_redraw()
   " Create two popups with a filter that closes the popup when typing "0".
   " Both popups should close, even though the redraw also calls
index 7debc1ab7d9e73b61f44a0ca76936361f023067b..f50c414a4f9e8f4409f6ee5173cd1c32a486dae7 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1230,
 /**/
     1229,
 /**/