patch 9.1.1230: inconsistent CTRL-C behaviour for popup windows

Commit: 
https://github.com/vim/vim/commit/8a63529a2f84bb5069b5f5e38f1704a541d067ad
Author: glepnir <glephun...@gmail.com>
Date:   Fri Mar 21 18:12:32 2025 +0100

    patch 9.1.1230: inconsistent CTRL-C behaviour for popup windows
    
    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 <glephun...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt
index 39eb5442b..f11040c4e 100644
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -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
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 6ecf64264..377ab2ae0 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -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 ~
diff --git a/src/popupwin.c b/src/popupwin.c
index 2032492a9..76ebf38e5 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -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;
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index e1041ef20..5082676ea 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 7debc1ab7..f50c414a4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1230,
 /**/
     1229,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1tvfxY-0072S0-NZ%40256bit.org.

Raspunde prin e-mail lui