Revert "vim-patch:8.1.1192: mode is not cleared when leaving Insert mode with mapped Esc"

This reverts commit 44bb7147e4.

Avoid regression mentioned in c64cce906e (commitcomment-45554271)
This commit is contained in:
Jan Edmund Lazo 2020-12-31 15:38:45 -05:00
parent 74b343a6f2
commit 723e009214
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
12 changed files with 44 additions and 122 deletions

View File

@ -3713,9 +3713,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
redraw_later(curwin, SOME_VALID); redraw_later(curwin, SOME_VALID);
curwin->w_p_fen = save_p_fen; curwin->w_p_fen = save_p_fen;
if (msg_row == Rows - 1) { if (msg_row == Rows - 1)
msg_didout = false; // avoid a scroll-up msg_didout = FALSE; /* avoid a scroll-up */
}
msg_starthere(); msg_starthere();
i = msg_scroll; i = msg_scroll;
msg_scroll = 0; /* truncate msg when msg_scroll = 0; /* truncate msg when
@ -3734,8 +3733,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
typed = plain_vgetc(); typed = plain_vgetc();
no_mapping--; no_mapping--;
// clear the question /* clear the question */
msg_didout = false; // don't scroll up msg_didout = FALSE; /* don't scroll up */
msg_col = 0; msg_col = 0;
gotocmdline(TRUE); gotocmdline(TRUE);

View File

@ -8069,8 +8069,8 @@ static void ex_redraw(exarg_T *eap)
RedrawingDisabled = r; RedrawingDisabled = r;
p_lz = p; p_lz = p;
// Reset msg_didout, so that a message that's there is overwritten. /* Reset msg_didout, so that a message that's there is overwritten. */
msg_didout = false; msg_didout = FALSE;
msg_col = 0; msg_col = 0;
/* No need to wait after an intentional redraw. */ /* No need to wait after an intentional redraw. */

View File

@ -2746,8 +2746,8 @@ redraw:
no_mapping--; no_mapping--;
// make following messages go to the next line /* make following messages go to the next line */
msg_didout = false; msg_didout = FALSE;
msg_col = 0; msg_col = 0;
if (msg_row < Rows - 1) { if (msg_row < Rows - 1) {
msg_row++; msg_row++;

View File

@ -139,9 +139,8 @@ 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 bool redraw_mode INIT(= false); // mode must be redrawn
EXTERN int clear_cmdline INIT(= false); // cmdline must be cleared EXTERN int clear_cmdline INIT(= false); // cmdline must be cleared
EXTERN bool mode_displayed INIT(= false); // mode is being displayed EXTERN int mode_displayed INIT(= false); // mode is being displayed
EXTERN int cmdline_star INIT(= false); // cmdline is crypted EXTERN int cmdline_star INIT(= false); // cmdline is crypted
EXTERN int redrawing_cmdline INIT(= false); // cmdline is being redrawn EXTERN int redrawing_cmdline INIT(= false); // cmdline is being redrawn
EXTERN int cmdline_was_last_drawn INIT(= false); // cmdline was last drawn EXTERN int cmdline_was_last_drawn INIT(= false); // cmdline was last drawn
@ -200,7 +199,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 keep_msg_more INIT(= false); // keep_msg was set by msgmore()
EXTERN int need_fileinfo INIT(= false); // do fileinfo() after redraw EXTERN int need_fileinfo INIT(= false); // do fileinfo() after redraw
EXTERN int msg_scroll INIT(= false); // msg_start() will scroll EXTERN int msg_scroll INIT(= false); // msg_start() will scroll
EXTERN bool msg_didout INIT(= false); // msg_outstr() was used in line EXTERN int 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_didany INIT(= false); // msg_outstr() was used at all
EXTERN int msg_nowait INIT(= false); // don't wait for this msg EXTERN int msg_nowait INIT(= false); // don't wait for this msg
EXTERN int emsg_off INIT(= 0); // don't display errors for now, EXTERN int emsg_off INIT(= 0); // don't display errors for now,

View File

@ -2006,7 +2006,7 @@ static void version(void)
info_message = TRUE; // use mch_msg(), not mch_errmsg() info_message = TRUE; // use mch_msg(), not mch_errmsg()
list_version(); list_version();
msg_putchar('\n'); msg_putchar('\n');
msg_didout = false; msg_didout = FALSE;
} }
/// Prints help message for "nvim -h" or "nvim --help". /// Prints help message for "nvim -h" or "nvim --help".

View File

@ -1128,11 +1128,11 @@ void wait_return(int redraw)
if (p_more) { if (p_more) {
if (c == 'b' || c == 'k' || c == 'u' || c == 'g' if (c == 'b' || c == 'k' || c == 'u' || c == 'g'
|| c == K_UP || c == K_PAGEUP) { || c == K_UP || c == K_PAGEUP) {
if (msg_scrolled > Rows) { if (msg_scrolled > Rows)
// scroll back to show older messages /* scroll back to show older messages */
do_more_prompt(c); do_more_prompt(c);
} else { else {
msg_didout = false; msg_didout = FALSE;
c = K_IGNORE; c = K_IGNORE;
msg_col = msg_col =
cmdmsg_rl ? Columns - 1 : cmdmsg_rl ? Columns - 1 :
@ -2097,17 +2097,15 @@ 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); store_sb_text((char_u **)&sb_str, (char_u *)s, attr, &sb_col, true);
} }
if (*s == '\n') { // go to next line if (*s == '\n') { /* go to next line */
msg_didout = false; // remember that line is empty msg_didout = FALSE; /* remember that line is empty */
if (cmdmsg_rl) { if (cmdmsg_rl)
msg_col = Columns - 1; msg_col = Columns - 1;
} else { else
msg_col = 0; msg_col = 0;
} if (++msg_row >= Rows) /* safety check */
if (++msg_row >= Rows) { // safety check
msg_row = Rows - 1; msg_row = Rows - 1;
} } else if (*s == '\r') { /* go to column 0 */
} else if (*s == '\r') { // go to column 0
msg_col = 0; msg_col = 0;
} else if (*s == '\b') { /* go to previous char */ } else if (*s == '\b') { /* go to previous char */
if (msg_col) if (msg_col)
@ -2880,10 +2878,10 @@ void repeat_message(void)
ui_cursor_goto(msg_row, msg_col); /* put cursor back */ ui_cursor_goto(msg_row, msg_col); /* put cursor back */
} else if (State == HITRETURN || State == SETWSIZE) { } else if (State == HITRETURN || State == SETWSIZE) {
if (msg_row == Rows - 1) { if (msg_row == Rows - 1) {
// Avoid drawing the "hit-enter" prompt below the previous one, /* Avoid drawing the "hit-enter" prompt below the previous one,
// overwrite it. Esp. useful when regaining focus and a * overwrite it. Esp. useful when regaining focus and a
// FocusGained autocmd exists but didn't draw anything. * FocusGained autocmd exists but didn't draw anything. */
msg_didout = false; msg_didout = FALSE;
msg_col = 0; msg_col = 0;
msg_clr_eos(); msg_clr_eos();
} }

View File

@ -620,7 +620,7 @@ int update_screen(int type)
/* 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 || redraw_mode) { if (clear_cmdline || redraw_cmdline) {
showmode(); showmode();
} }
@ -6569,7 +6569,7 @@ bool skip_showmode(void)
|| msg_silent != 0 || msg_silent != 0
|| !redrawing() || !redrawing()
|| (char_avail() && !KeyTyped)) { || (char_avail() && !KeyTyped)) {
redraw_mode = true; // show mode later redraw_cmdline = true; // show mode later
return true; return true;
} }
return false; return false;
@ -6580,7 +6580,6 @@ bool skip_showmode(void)
// 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 showmode(void) int showmode(void)
{ {
@ -6727,11 +6726,10 @@ int showmode(void)
need_clear = true; need_clear = true;
} }
mode_displayed = true; mode_displayed = TRUE;
if (need_clear || clear_cmdline || redraw_mode) { if (need_clear || clear_cmdline)
msg_clr_eos(); msg_clr_eos();
} msg_didout = FALSE; /* overwrite this message */
msg_didout = false; // overwrite this message
length = msg_col; length = msg_col;
msg_col = 0; msg_col = 0;
msg_no_more = false; msg_no_more = false;
@ -6740,9 +6738,6 @@ int 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();
} }
// NB: also handles clearing the showmode if it was emtpy or disabled // NB: also handles clearing the showmode if it was emtpy or disabled
@ -6759,7 +6754,6 @@ int showmode(void)
win_redr_ruler(last, true); win_redr_ruler(last, true);
} }
redraw_cmdline = false; redraw_cmdline = false;
redraw_mode = false;
clear_cmdline = false; clear_cmdline = false;
return length; return length;

View File

@ -3942,7 +3942,7 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int
msg_start(); msg_start();
msg_puts(_(msg_compressing)); msg_puts(_(msg_compressing));
msg_clr_eos(); msg_clr_eos();
msg_didout = false; msg_didout = FALSE;
msg_col = 0; msg_col = 0;
ui_flush(); ui_flush();
} }

View File

@ -120,34 +120,6 @@ func Test_mode_message_at_leaving_insert_by_ctrl_c()
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
func Test_echospace() func Test_echospace()
set noruler noshowcmd laststatus=1 set noruler noshowcmd laststatus=1
call assert_equal(&columns - 1, v:echospace) call assert_equal(&columns - 1, v:echospace)

View File

@ -391,7 +391,7 @@ describe('TUI', function()
{1:x} | {1:x} |
{4:~ }| {4:~ }|
{5:[No Name] [+] 3,1 All}| {5:[No Name] [+] 3,1 All}|
| :set ruler |
{3:-- TERMINAL --} | {3:-- TERMINAL --} |
]] ]]
local expected_attr = { local expected_attr = {

View File

@ -5344,45 +5344,6 @@ describe('floatwin', function()
-- at least. Also check invisible EndOfBuffer region blends correctly. -- at least. Also check invisible EndOfBuffer region blends correctly.
meths.buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"}) meths.buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"})
win = meths.open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'}) win = meths.open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'})
if multigrid then
screen:expect{grid=[[
## grid 1
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[2:----------------------------------------]|
[3:----------------------------------------]|
## grid 2
# TODO: |
# FIXME: ^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
## grid 3
|
## grid 6
{1: x x x xx}|
{1: x x x x}|
{1: }|
]], float_pos={
[6] = { {
id = 1003
}, "NW", 1, 0, 11, true }
}}
else
screen:expect{grid=[[
# TODO: {1: x x x xx} |
# FIXME: {1: x x x x}^ |
{0:~ }{1: }{0: }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]]}
end
meths.win_set_option(win, 'winblend', 30) meths.win_set_option(win, 'winblend', 30)
screen:set_default_attr_ids({ screen:set_default_attr_ids({
[1] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')}, [1] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')},
@ -5420,7 +5381,7 @@ describe('floatwin', function()
}, "NW", 1, 0, 11, true } }, "NW", 1, 0, 11, true }
}} }}
else else
screen:expect{grid=[[ screen:expect([[
# TODO: {2: x x x}{1:}{2: xx} | # TODO: {2: x x x}{1:}{2: xx} |
# FIXME: {1:}{2:x x x}{1:}{2: x}^ | # FIXME: {1:}{2:x x x}{1:}{2: x}^ |
{3:~ }{4: }{3: }| {3:~ }{4: }{3: }|
@ -5428,7 +5389,7 @@ describe('floatwin', function()
{3:~ }| {3:~ }|
{3:~ }| {3:~ }|
| |
]]} ]])
end end
meths.win_set_config(win, {relative='editor', row=0, col=12}) meths.win_set_config(win, {relative='editor', row=0, col=12})

View File

@ -20,7 +20,6 @@ describe('search highlighting', function()
[2] = {background = colors.Yellow}, -- Search [2] = {background = colors.Yellow}, -- Search
[3] = {reverse = true}, [3] = {reverse = true},
[4] = {foreground = colors.Red}, -- Message [4] = {foreground = colors.Red}, -- Message
[5] = {bold = true, reverse = true},
[6] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey}, -- Folded [6] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey}, -- Folded
}) })
end) end)
@ -176,15 +175,7 @@ describe('search highlighting', function()
]]) ]])
feed('/foo') feed('/foo')
helpers.poke_eventloop() helpers.poke_eventloop()
screen:expect{grid=[[ screen:expect_unchanged()
{3:foo} bar baz {3:} |
bar baz {2:foo} {3:} |
bar {2:foo} baz {3:} |
{3:} |
{1:~ }{3:} |
{5:[No Name] [+] }{3:term }|
/foo^ |
]]}
end) end)
it('works with incsearch', function() it('works with incsearch', function()
@ -483,7 +474,15 @@ describe('search highlighting', function()
-- check hilights work also in folds -- check hilights work also in folds
feed("zf4j") feed("zf4j")
command("%foldopen") command("%foldopen")
screen:expect_unchanged() screen:expect([[
very {5:spec^ial}{2: te}{6:xt} |
|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{4:search hit BOTTOM, continuing at TOP} |
]])
feed_command("call clearmatches()") feed_command("call clearmatches()")
screen:expect([[ screen:expect([[