]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1915: r_CTRL-C works differently in visual mode v9.0.1915
authorChristian Brabandt <cb@256bit.org>
Tue, 19 Sep 2023 18:41:51 +0000 (20:41 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 19 Sep 2023 18:45:07 +0000 (20:45 +0200)
Problem:  r_CTRL-C works differently in visual mode
Solution: Make r_CTRL-C behave consistent in visual mode
          in terminal and Windows GUI

in visual mode, r CTRL-C behaves strange in Unix like environments. It
seems to end visual mode, but still is waiting for few more chars,
however it never seems to replace it by any characters and eventually
just returns back into normal mode.

In contrast in Windows GUI mode, r_CTRL-C replaces in the selected area
all characters by a literal CTRL-C.

Not sure why it behaves like this. It seems in the Windows GUI, got_int
is not set and therefore behaves as if any other normal character has
been pressed.

So remove the special casing of what happens when got_int is set and
make it always behave like in Windows GUI mode. Add a test to verify it
always behaves like replacing in the selected area each selected
character by a literal CTRL-C.

closes: #13091
closes: #13112

Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/change.txt
runtime/doc/visual.txt
src/normal.c
src/testdir/test_visual.vim
src/version.c

index a00049bef3b5e7666527523a7c5cac33cf9284a9..65da9a7c6b92b6ec0994857177e64201a4106934 100644 (file)
@@ -1,4 +1,4 @@
-*change.txt*    For Vim version 9.0.  Last change: 2023 Mar 07
+*change.txt*    For Vim version 9.0.  Last change: 2023 Sep 19
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -210,6 +210,7 @@ gR                  Enter Virtual Replace mode: Each character you type
 
                                                        *v_r*
 {Visual}r{char}                Replace all selected characters by {char}.
+                       CTRL-C will be inserted literally.
 
                                                        *v_C*
 {Visual}["x]C          Delete the highlighted lines [into register x] and
index 540d5c574f6f704fe13930663f39fad8bd187a8d..616e773fe3fc11b2193cc881212547d37969cde3 100644 (file)
@@ -1,4 +1,4 @@
-*visual.txt*    For Vim version 9.0.  Last change: 2022 Dec 04
+*visual.txt*    For Vim version 9.0.  Last change: 2023 Sep 19
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -183,6 +183,8 @@ If you want to highlight exactly the same area as the last time, you can use
 CTRL-C                 In Visual mode: Stop Visual mode.  When insert mode is
                        pending (the mode message shows
                        "-- (insert) VISUAL --"), it is also stopped.
+                       On MS-Windows, you may need to press CTRL-Break 
+                       |dos-CTRL-Break|.
 
 ==============================================================================
 3. Changing the Visual area                            *visual-change*
index 86b8740f8a465fedf9d965397655875bcb1213d4..9f203b858768e89fabc2f7e370f01b90819a9627 100644 (file)
@@ -4799,7 +4799,7 @@ nv_replace(cmdarg_T *cap)
     if (VIsual_active)
     {
        if (got_int)
-           reset_VIsual();
+           got_int = FALSE;
        if (had_ctrl_v)
        {
            // Use a special (negative) number to make a difference between a
index 58b73929479a45d2756a37b152c731ed5968b6a1..290641e1df71a7e3cddb0d240e0645d32b48bdcb 100644 (file)
@@ -1573,4 +1573,18 @@ func Test_visual_hl_with_showbreak()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_Visual_r_CTRL_C()
+  new
+  " visual r_cmd
+  call setline(1, ['   '])
+  call feedkeys("\<c-v>$r\<c-c>", 'tx')
+  call assert_equal(['\ 3\ 3\ 3'], getline(1, 1))
+
+  " visual gr_cmd
+  call setline(1, ['   '])
+  call feedkeys("\<c-v>$gr\<c-c>", 'tx')
+  call assert_equal(['\ 3\ 3\ 3'], getline(1, 1))
+  bw!
+endfu
+
 " vim: shiftwidth=2 sts=2 expandtab
index 809fb608112b0c67593d06cb6ff4abca4b8115fc..03cb97fd05dc17d027dc2967d565553b3b0fce53 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1915,
 /**/
     1914,
 /**/