mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 9.0.1347: "gr CTRL-O" stays in Insert mode
Problem: "gr CTRL-O" stays in Insert mode. (Pierre Ganty) Solution: Do not set restart_edit when "cmdchar" is 'v'. (closes #12045)
This commit is contained in:
15
src/edit.c
15
src/edit.c
@@ -45,7 +45,7 @@ static void ins_ctrl_(void);
|
|||||||
#endif
|
#endif
|
||||||
static int ins_start_select(int c);
|
static int ins_start_select(int c);
|
||||||
static void ins_insert(int replaceState);
|
static void ins_insert(int replaceState);
|
||||||
static void ins_ctrl_o(void);
|
static void ins_ctrl_o(int cmdchar);
|
||||||
static void ins_shift(int c, int lastc);
|
static void ins_shift(int c, int lastc);
|
||||||
static void ins_del(void);
|
static void ins_del(void);
|
||||||
static int ins_bs(int c, int mode, int *inserted_space_p);
|
static int ins_bs(int c, int mode, int *inserted_space_p);
|
||||||
@@ -429,7 +429,8 @@ edit(
|
|||||||
/*
|
/*
|
||||||
* Main loop in Insert mode: repeat until Insert mode is left.
|
* Main loop in Insert mode: repeat until Insert mode is left.
|
||||||
*/
|
*/
|
||||||
for (;;)
|
int did_loop = FALSE;
|
||||||
|
for (;; did_loop = TRUE)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_RIGHTLEFT
|
#ifdef FEAT_RIGHTLEFT
|
||||||
if (!revins_legal)
|
if (!revins_legal)
|
||||||
@@ -588,6 +589,8 @@ edit(
|
|||||||
if (cmdchar == K_PS)
|
if (cmdchar == K_PS)
|
||||||
// Got here from normal mode when bracketed paste started.
|
// Got here from normal mode when bracketed paste started.
|
||||||
c = K_PS;
|
c = K_PS;
|
||||||
|
else if (cmdchar == 'v' && did_loop)
|
||||||
|
c = ESC; // in case the stuffed Esc was consumed already
|
||||||
else
|
else
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -717,7 +720,7 @@ edit(
|
|||||||
{
|
{
|
||||||
if (c == Ctrl_O)
|
if (c == Ctrl_O)
|
||||||
{
|
{
|
||||||
ins_ctrl_o();
|
ins_ctrl_o(cmdchar);
|
||||||
ins_at_eol = FALSE; // cursor keeps its column
|
ins_at_eol = FALSE; // cursor keeps its column
|
||||||
nomove = TRUE;
|
nomove = TRUE;
|
||||||
}
|
}
|
||||||
@@ -860,7 +863,7 @@ doESCkey:
|
|||||||
#endif
|
#endif
|
||||||
if (echeck_abbr(Ctrl_O + ABBR_OFF))
|
if (echeck_abbr(Ctrl_O + ABBR_OFF))
|
||||||
break;
|
break;
|
||||||
ins_ctrl_o();
|
ins_ctrl_o(cmdchar);
|
||||||
|
|
||||||
// don't move the cursor left when 'virtualedit' has "onemore".
|
// don't move the cursor left when 'virtualedit' has "onemore".
|
||||||
if (get_ve_flags() & VE_ONEMORE)
|
if (get_ve_flags() & VE_ONEMORE)
|
||||||
@@ -3848,8 +3851,10 @@ ins_insert(int replaceState)
|
|||||||
* Pressed CTRL-O in Insert mode.
|
* Pressed CTRL-O in Insert mode.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
ins_ctrl_o(void)
|
ins_ctrl_o(int cmdchar)
|
||||||
{
|
{
|
||||||
|
if (cmdchar == 'v')
|
||||||
|
return; // abort replacing one char for gr CTRL-O
|
||||||
if (State & VREPLACE_FLAG)
|
if (State & VREPLACE_FLAG)
|
||||||
restart_edit = 'V';
|
restart_edit = 'V';
|
||||||
else if (State & REPLACE_FLAG)
|
else if (State & REPLACE_FLAG)
|
||||||
|
@@ -2064,6 +2064,16 @@ func Test_edit_CTRL_hat()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
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
|
" Weird long file name was going over the end of NameBuff
|
||||||
func Test_edit_overlong_file_name()
|
func Test_edit_overlong_file_name()
|
||||||
CheckUnix
|
CheckUnix
|
||||||
|
@@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1347,
|
||||||
/**/
|
/**/
|
||||||
1346,
|
1346,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user