changeset 33299:4c975fa0a442 v9.0.1915

patch 9.0.1915: r_CTRL-C works differently in visual mode Commit: https://github.com/vim/vim/commit/476733f3d06876c7ac105e064108c973a57984d3 Author: Christian Brabandt <cb@256bit.org> Date: Tue Sep 19 20:41:51 2023 +0200 patch 9.0.1915: r_CTRL-C works differently in visual mode 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>
author Christian Brabandt <cb@256bit.org>
date Tue, 19 Sep 2023 21:00:03 +0200
parents b5879bdef29e
children b73d6daab5a7
files runtime/doc/change.txt runtime/doc/visual.txt src/normal.c src/testdir/test_visual.vim src/version.c
diffstat 5 files changed, 22 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -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 ch
 
 							*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
--- a/runtime/doc/visual.txt
+++ b/runtime/doc/visual.txt
@@ -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 sam
 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*
--- a/src/normal.c
+++ b/src/normal.c
@@ -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
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -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([''], getline(1, 1))
+
+  " visual gr_cmd
+  call setline(1, ['   '])
+  call feedkeys("\<c-v>$gr\<c-c>", 'tx')
+  call assert_equal([''], getline(1, 1))
+  bw!
+endfu
+
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1915,
+/**/
     1914,
 /**/
     1913,