mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
vim-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 vim/vim#4269)
4c25bd785a
This commit is contained in:
@@ -3712,8 +3712,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
|
||||
redraw_later(curwin, SOME_VALID);
|
||||
|
||||
curwin->w_p_fen = save_p_fen;
|
||||
if (msg_row == Rows - 1)
|
||||
msg_didout = FALSE; /* avoid a scroll-up */
|
||||
if (msg_row == Rows - 1) {
|
||||
msg_didout = false; // avoid a scroll-up
|
||||
}
|
||||
msg_starthere();
|
||||
i = msg_scroll;
|
||||
msg_scroll = 0; /* truncate msg when
|
||||
@@ -3732,8 +3733,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
|
||||
typed = plain_vgetc();
|
||||
no_mapping--;
|
||||
|
||||
/* clear the question */
|
||||
msg_didout = FALSE; /* don't scroll up */
|
||||
// clear the question
|
||||
msg_didout = false; // don't scroll up
|
||||
msg_col = 0;
|
||||
gotocmdline(TRUE);
|
||||
|
||||
|
@@ -8062,8 +8062,8 @@ static void ex_redraw(exarg_T *eap)
|
||||
RedrawingDisabled = r;
|
||||
p_lz = p;
|
||||
|
||||
/* Reset msg_didout, so that a message that's there is overwritten. */
|
||||
msg_didout = FALSE;
|
||||
// Reset msg_didout, so that a message that's there is overwritten.
|
||||
msg_didout = false;
|
||||
msg_col = 0;
|
||||
|
||||
/* No need to wait after an intentional redraw. */
|
||||
|
@@ -2740,8 +2740,8 @@ redraw:
|
||||
|
||||
no_mapping--;
|
||||
|
||||
/* make following messages go to the next line */
|
||||
msg_didout = FALSE;
|
||||
// make following messages go to the next line
|
||||
msg_didout = false;
|
||||
msg_col = 0;
|
||||
if (msg_row < Rows - 1) {
|
||||
msg_row++;
|
||||
|
@@ -139,8 +139,9 @@ EXTERN int mod_mask INIT(= 0x0); // current key modifiers
|
||||
EXTERN int cmdline_row;
|
||||
|
||||
EXTERN int redraw_cmdline INIT(= false); // cmdline must be redrawn
|
||||
EXTERN bool redraw_mode INIT(= false); // mode must be redrawn
|
||||
EXTERN int clear_cmdline INIT(= false); // cmdline must be cleared
|
||||
EXTERN int mode_displayed INIT(= false); // mode is being displayed
|
||||
EXTERN bool mode_displayed INIT(= false); // mode is being displayed
|
||||
EXTERN int cmdline_star INIT(= false); // cmdline is crypted
|
||||
EXTERN int redrawing_cmdline INIT(= false); // cmdline is being redrawn
|
||||
EXTERN int cmdline_was_last_drawn INIT(= false); // cmdline was last drawn
|
||||
@@ -199,7 +200,7 @@ EXTERN int keep_msg_attr INIT(= 0); // highlight attr for keep_msg
|
||||
EXTERN int keep_msg_more INIT(= false); // keep_msg was set by msgmore()
|
||||
EXTERN int need_fileinfo INIT(= false); // do fileinfo() after redraw
|
||||
EXTERN int msg_scroll INIT(= false); // msg_start() will scroll
|
||||
EXTERN int msg_didout INIT(= false); // msg_outstr() was used in line
|
||||
EXTERN bool msg_didout INIT(= false); // msg_outstr() was used in line
|
||||
EXTERN int msg_didany INIT(= false); // msg_outstr() was used at all
|
||||
EXTERN int msg_nowait INIT(= false); // don't wait for this msg
|
||||
EXTERN int emsg_off INIT(= 0); // don't display errors for now,
|
||||
|
@@ -2006,7 +2006,7 @@ static void version(void)
|
||||
info_message = TRUE; // use mch_msg(), not mch_errmsg()
|
||||
list_version();
|
||||
msg_putchar('\n');
|
||||
msg_didout = FALSE;
|
||||
msg_didout = false;
|
||||
}
|
||||
|
||||
/// Prints help message for "nvim -h" or "nvim --help".
|
||||
|
@@ -1128,11 +1128,11 @@ void wait_return(int redraw)
|
||||
if (p_more) {
|
||||
if (c == 'b' || c == 'k' || c == 'u' || c == 'g'
|
||||
|| c == K_UP || c == K_PAGEUP) {
|
||||
if (msg_scrolled > Rows)
|
||||
/* scroll back to show older messages */
|
||||
if (msg_scrolled > Rows) {
|
||||
// scroll back to show older messages
|
||||
do_more_prompt(c);
|
||||
else {
|
||||
msg_didout = FALSE;
|
||||
} else {
|
||||
msg_didout = false;
|
||||
c = K_IGNORE;
|
||||
msg_col =
|
||||
cmdmsg_rl ? Columns - 1 :
|
||||
@@ -2097,15 +2097,17 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr,
|
||||
store_sb_text((char_u **)&sb_str, (char_u *)s, attr, &sb_col, true);
|
||||
}
|
||||
|
||||
if (*s == '\n') { /* go to next line */
|
||||
msg_didout = FALSE; /* remember that line is empty */
|
||||
if (cmdmsg_rl)
|
||||
if (*s == '\n') { // go to next line
|
||||
msg_didout = false; // remember that line is empty
|
||||
if (cmdmsg_rl) {
|
||||
msg_col = Columns - 1;
|
||||
else
|
||||
} else {
|
||||
msg_col = 0;
|
||||
if (++msg_row >= Rows) /* safety check */
|
||||
}
|
||||
if (++msg_row >= Rows) { // safety check
|
||||
msg_row = Rows - 1;
|
||||
} else if (*s == '\r') { /* go to column 0 */
|
||||
}
|
||||
} else if (*s == '\r') { // go to column 0
|
||||
msg_col = 0;
|
||||
} else if (*s == '\b') { /* go to previous char */
|
||||
if (msg_col)
|
||||
@@ -2878,10 +2880,10 @@ void repeat_message(void)
|
||||
ui_cursor_goto(msg_row, msg_col); /* put cursor back */
|
||||
} else if (State == HITRETURN || State == SETWSIZE) {
|
||||
if (msg_row == Rows - 1) {
|
||||
/* Avoid drawing the "hit-enter" prompt below the previous one,
|
||||
* overwrite it. Esp. useful when regaining focus and a
|
||||
* FocusGained autocmd exists but didn't draw anything. */
|
||||
msg_didout = FALSE;
|
||||
// Avoid drawing the "hit-enter" prompt below the previous one,
|
||||
// overwrite it. Esp. useful when regaining focus and a
|
||||
// FocusGained autocmd exists but didn't draw anything.
|
||||
msg_didout = false;
|
||||
msg_col = 0;
|
||||
msg_clr_eos();
|
||||
}
|
||||
|
@@ -620,7 +620,7 @@ int update_screen(int type)
|
||||
|
||||
/* Clear or redraw the command line. Done last, because scrolling may
|
||||
* mess up the command line. */
|
||||
if (clear_cmdline || redraw_cmdline) {
|
||||
if (clear_cmdline || redraw_cmdline || redraw_mode) {
|
||||
showmode();
|
||||
}
|
||||
|
||||
@@ -6567,7 +6567,7 @@ bool skip_showmode(void)
|
||||
|| msg_silent != 0
|
||||
|| !redrawing()
|
||||
|| (char_avail() && !KeyTyped)) {
|
||||
redraw_cmdline = true; // show mode later
|
||||
redraw_mode = true; // show mode later
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -6578,6 +6578,7 @@ bool skip_showmode(void)
|
||||
// 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
|
||||
// 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).
|
||||
int showmode(void)
|
||||
{
|
||||
@@ -6724,10 +6725,11 @@ int showmode(void)
|
||||
need_clear = true;
|
||||
}
|
||||
|
||||
mode_displayed = TRUE;
|
||||
if (need_clear || clear_cmdline)
|
||||
mode_displayed = true;
|
||||
if (need_clear || clear_cmdline || redraw_mode) {
|
||||
msg_clr_eos();
|
||||
msg_didout = FALSE; /* overwrite this message */
|
||||
}
|
||||
msg_didout = false; // overwrite this message
|
||||
length = msg_col;
|
||||
msg_col = 0;
|
||||
msg_no_more = false;
|
||||
@@ -6736,6 +6738,9 @@ int showmode(void)
|
||||
} else if (clear_cmdline && msg_silent == 0) {
|
||||
// Clear the whole command line. Will reset "clear_cmdline".
|
||||
msg_clr_cmdline();
|
||||
} else if (redraw_mode) {
|
||||
msg_pos_mode();
|
||||
msg_clr_eos();
|
||||
}
|
||||
|
||||
// NB: also handles clearing the showmode if it was emtpy or disabled
|
||||
@@ -6752,6 +6757,7 @@ int showmode(void)
|
||||
win_redr_ruler(last, true);
|
||||
}
|
||||
redraw_cmdline = false;
|
||||
redraw_mode = false;
|
||||
clear_cmdline = false;
|
||||
|
||||
return length;
|
||||
|
@@ -3942,7 +3942,7 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int
|
||||
msg_start();
|
||||
msg_puts(_(msg_compressing));
|
||||
msg_clr_eos();
|
||||
msg_didout = FALSE;
|
||||
msg_didout = false;
|
||||
msg_col = 0;
|
||||
ui_flush();
|
||||
}
|
||||
|
@@ -120,6 +120,34 @@ func Test_mode_message_at_leaving_insert_by_ctrl_c()
|
||||
call delete(testfile)
|
||||
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
|
||||
|
||||
func Test_echospace()
|
||||
set noruler noshowcmd laststatus=1
|
||||
call assert_equal(&columns - 1, v:echospace)
|
||||
|
Reference in New Issue
Block a user