mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06: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:
parent
53b0688ac0
commit
93ba821831
@ -145,6 +145,7 @@ EXTERN int vgetc_char INIT(= 0);
|
|||||||
EXTERN int cmdline_row;
|
EXTERN int cmdline_row;
|
||||||
|
|
||||||
EXTERN bool redraw_cmdline INIT(= false); // cmdline must be redrawn
|
EXTERN bool redraw_cmdline INIT(= false); // cmdline must be redrawn
|
||||||
|
EXTERN bool redraw_mode INIT(= false); // mode must be redrawn
|
||||||
EXTERN bool clear_cmdline INIT(= false); // cmdline must be cleared
|
EXTERN bool clear_cmdline INIT(= false); // cmdline must be cleared
|
||||||
EXTERN bool 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 encrypted
|
EXTERN int cmdline_star INIT(= false); // cmdline is encrypted
|
||||||
|
@ -591,7 +591,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) {
|
if (clear_cmdline || redraw_cmdline || redraw_mode) {
|
||||||
showmode();
|
showmode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5828,18 +5828,19 @@ bool skip_showmode(void)
|
|||||||
// Call char_avail() only when we are going to show something, because it
|
// Call char_avail() only when we are going to show something, because it
|
||||||
// takes a bit of time. redrawing() may also call char_avail().
|
// takes a bit of time. redrawing() may also call char_avail().
|
||||||
if (global_busy || msg_silent != 0 || !redrawing() || (char_avail() && !KeyTyped)) {
|
if (global_busy || msg_silent != 0 || !redrawing() || (char_avail() && !KeyTyped)) {
|
||||||
redraw_cmdline = true; // show mode later
|
redraw_mode = true; // show mode later
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the current mode and ruler.
|
/// Show the current mode and ruler.
|
||||||
//
|
///
|
||||||
// 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.
|
||||||
// Return the length of the message (0 if no message).
|
/// If redraw_mode is true show or clear the mode.
|
||||||
|
/// @return the length of the message (0 if no message).
|
||||||
int showmode(void)
|
int showmode(void)
|
||||||
{
|
{
|
||||||
bool need_clear;
|
bool need_clear;
|
||||||
@ -5998,7 +5999,7 @@ int 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
|
||||||
@ -6010,6 +6011,9 @@ 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 empty or disabled
|
// NB: also handles clearing the showmode if it was empty or disabled
|
||||||
@ -6027,6 +6031,7 @@ 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;
|
||||||
|
@ -126,6 +126,34 @@ 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)
|
||||||
|
@ -376,6 +376,32 @@ describe('messages', function()
|
|||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_mode_message_at_leaving_insert_with_esc_mapped()
|
||||||
|
it('leaving Insert mode with ESC in the middle of a mapping vim-patch:8.1.1192', function()
|
||||||
|
exec([[
|
||||||
|
set laststatus=2
|
||||||
|
inoremap <Esc> <Esc>00
|
||||||
|
]])
|
||||||
|
feed('i')
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{3:[No Name] }|
|
||||||
|
{2:-- INSERT --} |
|
||||||
|
]])
|
||||||
|
feed('<Esc>')
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{1:~ }|
|
||||||
|
{3:[No Name] }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- oldtest: Test_ask_yesno()
|
-- oldtest: Test_ask_yesno()
|
||||||
|
Loading…
Reference in New Issue
Block a user