Patch 9.0.1347
Problem: "gr CTRL-O" stays in Insert mode. (Pierre Ganty)
Solution: Do not set restart_edit when "cmdchar" is 'v'. (closes #12045)
Files: src/edit.c, src/testdir/test_edit.vim
*** ../vim-9.0.1346/src/edit.c 2023-02-21 14:27:34.516360384 +0000
--- src/edit.c 2023-02-23 20:08:57.235654401 +0000
***************
*** 45,51 ****
#endif
static int ins_start_select(int c);
static void ins_insert(int replaceState);
! static void ins_ctrl_o(void);
static void ins_shift(int c, int lastc);
static void ins_del(void);
static int ins_bs(int c, int mode, int *inserted_space_p);
--- 45,51 ----
#endif
static int ins_start_select(int c);
static void ins_insert(int replaceState);
! static void ins_ctrl_o(int cmdchar);
static void ins_shift(int c, int lastc);
static void ins_del(void);
static int ins_bs(int c, int mode, int *inserted_space_p);
***************
*** 429,435 ****
/*
* Main loop in Insert mode: repeat until Insert mode is left.
*/
! for (;;)
{
#ifdef FEAT_RIGHTLEFT
if (!revins_legal)
--- 429,436 ----
/*
* Main loop in Insert mode: repeat until Insert mode is left.
*/
! int did_loop = FALSE;
! for (;; did_loop = TRUE)
{
#ifdef FEAT_RIGHTLEFT
if (!revins_legal)
***************
*** 588,593 ****
--- 589,596 ----
if (cmdchar == K_PS)
// Got here from normal mode when bracketed paste started.
c = K_PS;
+ else if (cmdchar == 'v' && did_loop)
+ c = ESC; // in case the stuffed Esc was consumed already
else
do
{
***************
*** 717,723 ****
{
if (c == Ctrl_O)
{
! ins_ctrl_o();
ins_at_eol = FALSE; // cursor keeps its column
nomove = TRUE;
}
--- 720,726 ----
{
if (c == Ctrl_O)
{
! ins_ctrl_o(cmdchar);
ins_at_eol = FALSE; // cursor keeps its column
nomove = TRUE;
}
***************
*** 860,866 ****
#endif
if (echeck_abbr(Ctrl_O + ABBR_OFF))
break;
! ins_ctrl_o();
// don't move the cursor left when 'virtualedit' has "onemore".
if (get_ve_flags() & VE_ONEMORE)
--- 863,869 ----
#endif
if (echeck_abbr(Ctrl_O + ABBR_OFF))
break;
! ins_ctrl_o(cmdchar);
// don't move the cursor left when 'virtualedit' has "onemore".
if (get_ve_flags() & VE_ONEMORE)
***************
*** 3848,3855 ****
* Pressed CTRL-O in Insert mode.
*/
static void
! ins_ctrl_o(void)
{
if (State & VREPLACE_FLAG)
restart_edit = 'V';
else if (State & REPLACE_FLAG)
--- 3851,3860 ----
* Pressed CTRL-O in Insert mode.
*/
static void
! ins_ctrl_o(int cmdchar)
{
+ if (cmdchar == 'v')
+ return; // abort replacing one char for gr CTRL-O
if (State & VREPLACE_FLAG)
restart_edit = 'V';
else if (State & REPLACE_FLAG)
*** ../vim-9.0.1346/src/testdir/test_edit.vim 2023-01-28 19:18:56.729720605
+0000
--- src/testdir/test_edit.vim 2023-02-23 20:12:09.526814021 +0000
***************
*** 2064,2069 ****
--- 2064,2079 ----
bwipe!
endfunc
+ " Test "gr" followed by an Insert mode command does get out of Insert mode.
+ func Test_edit_gr_special()
+ enew
+ call setline(1, ['abcdef', 'xxxxxx'])
+ exe "normal! gr\<C-O>x"
+ call assert_equal('bcdef', getline(1))
+
+ bwipe!
+ endfunc
+
" Weird long file name was going over the end of NameBuff
func Test_edit_overlong_file_name()
CheckUnix
*** ../vim-9.0.1346/src/version.c 2023-02-23 15:38:45.332355557 +0000
--- src/version.c 2023-02-23 20:04:03.461606456 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1347,
/**/
--
hundred-and-one symptoms of being an internet addict:
171. You invent another person and chat with yourself in empty chat rooms.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20230223201336.D411B1C0857%40moolenaar.net.