mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.1.1192: mode is not cleared when leaving Insert mode with mapped Esc
Problem: Mode is not cleared when leaving Insert mode with mapped Esc. Solution: Clear the mode when redraw_cmdline is set. (closes #4269)
This commit is contained in:
@@ -90,12 +90,13 @@ EXTERN int mod_mask INIT(= 0x0); /* current key modifiers */
|
|||||||
*/
|
*/
|
||||||
EXTERN int cmdline_row;
|
EXTERN int cmdline_row;
|
||||||
|
|
||||||
EXTERN int redraw_cmdline INIT(= FALSE); /* cmdline must be redrawn */
|
EXTERN int redraw_cmdline INIT(= FALSE); // cmdline must be redrawn
|
||||||
EXTERN int clear_cmdline INIT(= FALSE); /* cmdline must be cleared */
|
EXTERN int redraw_mode INIT(= FALSE); // mode must be redrawn
|
||||||
EXTERN int mode_displayed INIT(= FALSE); /* mode is being displayed */
|
EXTERN int clear_cmdline INIT(= FALSE); // cmdline must be cleared
|
||||||
EXTERN int no_win_do_lines_ins INIT(= FALSE); /* don't insert lines */
|
EXTERN int mode_displayed INIT(= FALSE); // mode is being displayed
|
||||||
|
EXTERN int no_win_do_lines_ins INIT(= FALSE); // don't insert lines
|
||||||
#if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
|
#if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
|
||||||
EXTERN int cmdline_star INIT(= FALSE); /* cmdline is crypted */
|
EXTERN int cmdline_star INIT(= FALSE); // cmdline is crypted
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXTERN int exec_from_reg INIT(= FALSE); /* executing register */
|
EXTERN int exec_from_reg INIT(= FALSE); /* executing register */
|
||||||
|
15
src/screen.c
15
src/screen.c
@@ -790,7 +790,7 @@ update_screen(int type_arg)
|
|||||||
|
|
||||||
/* Clear or redraw the command line. Done last, because scrolling may
|
/* Clear or redraw the command line. Done last, because scrolling may
|
||||||
* mess up the command line. */
|
* mess up the command line. */
|
||||||
if (clear_cmdline || redraw_cmdline)
|
if (clear_cmdline || redraw_cmdline || redraw_mode)
|
||||||
showmode();
|
showmode();
|
||||||
|
|
||||||
if (no_update)
|
if (no_update)
|
||||||
@@ -857,7 +857,7 @@ update_prepare(void)
|
|||||||
static void
|
static void
|
||||||
update_finish(void)
|
update_finish(void)
|
||||||
{
|
{
|
||||||
if (redraw_cmdline)
|
if (redraw_cmdline || redraw_mode)
|
||||||
showmode();
|
showmode();
|
||||||
|
|
||||||
# ifdef FEAT_SEARCH_EXTRA
|
# ifdef FEAT_SEARCH_EXTRA
|
||||||
@@ -10128,7 +10128,7 @@ skip_showmode()
|
|||||||
|| !redrawing()
|
|| !redrawing()
|
||||||
|| (char_avail() && !KeyTyped))
|
|| (char_avail() && !KeyTyped))
|
||||||
{
|
{
|
||||||
redraw_cmdline = TRUE; // show mode later
|
redraw_mode = TRUE; // show mode later
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -10140,6 +10140,7 @@ skip_showmode()
|
|||||||
* If clear_cmdline is TRUE, clear the rest of the cmdline.
|
* If clear_cmdline is TRUE, clear the rest of the cmdline.
|
||||||
* If clear_cmdline is FALSE there may be a message there that needs to be
|
* If clear_cmdline is FALSE there may be a message there that needs to be
|
||||||
* cleared only if a mode is shown.
|
* cleared only if a mode is shown.
|
||||||
|
* If redraw_mode is TRUE show or clear the mode.
|
||||||
* Return the length of the message (0 if no message).
|
* Return the length of the message (0 if no message).
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@@ -10313,7 +10314,7 @@ showmode(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mode_displayed = TRUE;
|
mode_displayed = TRUE;
|
||||||
if (need_clear || clear_cmdline)
|
if (need_clear || clear_cmdline || redraw_mode)
|
||||||
msg_clr_eos();
|
msg_clr_eos();
|
||||||
msg_didout = FALSE; /* overwrite this message */
|
msg_didout = FALSE; /* overwrite this message */
|
||||||
length = msg_col;
|
length = msg_col;
|
||||||
@@ -10323,6 +10324,11 @@ showmode(void)
|
|||||||
else if (clear_cmdline && msg_silent == 0)
|
else if (clear_cmdline && msg_silent == 0)
|
||||||
/* Clear the whole command line. Will reset "clear_cmdline". */
|
/* Clear the whole command line. Will reset "clear_cmdline". */
|
||||||
msg_clr_cmdline();
|
msg_clr_cmdline();
|
||||||
|
else if (redraw_mode)
|
||||||
|
{
|
||||||
|
msg_pos_mode();
|
||||||
|
msg_clr_eos();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef FEAT_CMDL_INFO
|
#ifdef FEAT_CMDL_INFO
|
||||||
/* In Visual mode the size of the selected area must be redrawn. */
|
/* In Visual mode the size of the selected area must be redrawn. */
|
||||||
@@ -10335,6 +10341,7 @@ showmode(void)
|
|||||||
win_redr_ruler(lastwin, TRUE, FALSE);
|
win_redr_ruler(lastwin, TRUE, FALSE);
|
||||||
#endif
|
#endif
|
||||||
redraw_cmdline = FALSE;
|
redraw_cmdline = FALSE;
|
||||||
|
redraw_mode = FALSE;
|
||||||
clear_cmdline = FALSE;
|
clear_cmdline = FALSE;
|
||||||
|
|
||||||
return length;
|
return length;
|
||||||
|
@@ -125,3 +125,31 @@ func Test_mode_message_at_leaving_insert_by_ctrl_c()
|
|||||||
exe buf . 'bwipe!'
|
exe buf . 'bwipe!'
|
||||||
call delete(testfile)
|
call delete(testfile)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_mode_message_at_leaving_insert_with_esc_mapped()
|
||||||
|
if !has('terminal') || has('gui_running')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Set custom statusline built by user-defined function.
|
||||||
|
let testfile = 'Xtest.vim'
|
||||||
|
call writefile([
|
||||||
|
\ 'set laststatus=2',
|
||||||
|
\ 'inoremap <Esc> <Esc>00',
|
||||||
|
\ ], testfile)
|
||||||
|
|
||||||
|
let rows = 10
|
||||||
|
let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
|
||||||
|
call term_wait(buf, 200)
|
||||||
|
call assert_equal('run', job_status(term_getjob(buf)))
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "i")
|
||||||
|
call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))})
|
||||||
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
|
call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":qall!\<CR>")
|
||||||
|
call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
|
||||||
|
exe buf . 'bwipe!'
|
||||||
|
call delete(testfile)
|
||||||
|
endfunc
|
||||||
|
@@ -771,6 +771,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 */
|
||||||
|
/**/
|
||||||
|
1192,
|
||||||
/**/
|
/**/
|
||||||
1191,
|
1191,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user