UI/cmdline: check if redraw is needed after K_EVENT, K_COMMAND #9804

fixes #8490
This commit is contained in:
Jit 2019-05-26 19:52:30 +02:00 committed by Justin M. Keyes
parent fc7861f0fa
commit 0bbaef8a99
5 changed files with 87 additions and 18 deletions

View File

@ -547,7 +547,10 @@ static int command_line_execute(VimState *state, int key)
} else {
do_cmdline(NULL, getcmdkeycmd, NULL, DOCMD_NOWAIT);
}
redrawcmdline();
if (!cmdline_was_last_drawn) {
redrawcmdline();
}
return 1;
}
@ -3457,6 +3460,8 @@ void redrawcmd(void)
return;
}
redrawing_cmdline = true;
msg_start();
redrawcmdprompt();
@ -3478,9 +3483,11 @@ void redrawcmd(void)
*/
msg_scroll = FALSE; /* next message overwrites cmdline */
/* Typing ':' at the more prompt may set skip_redraw. We don't want this
* in cmdline mode */
skip_redraw = FALSE;
// Typing ':' at the more prompt may set skip_redraw. We don't want this
// in cmdline mode.
skip_redraw = false;
redrawing_cmdline = false;
}
void compute_cmdrow(void)

View File

@ -146,12 +146,14 @@ EXTERN int mod_mask INIT(= 0x0); /* current key modifiers */
*/
EXTERN int cmdline_row;
EXTERN int redraw_cmdline INIT(= FALSE); /* cmdline must be redrawn */
EXTERN int clear_cmdline INIT(= FALSE); /* cmdline must be cleared */
EXTERN int mode_displayed INIT(= FALSE); /* mode is being displayed */
EXTERN int cmdline_star INIT(= FALSE); /* cmdline is crypted */
EXTERN int redraw_cmdline INIT(= false); // cmdline must be redrawn
EXTERN int clear_cmdline INIT(= false); // cmdline must be cleared
EXTERN int 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
EXTERN int exec_from_reg INIT(= FALSE); /* executing register */
EXTERN int exec_from_reg INIT(= false); // executing register
/*
* When '$' is included in 'cpoptions' option set:

View File

@ -1881,6 +1881,8 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr,
return;
}
cmdline_was_last_drawn = redrawing_cmdline;
while ((maxlen < 0 || (int)(s - str) < maxlen) && *s != NUL) {
// We are at the end of the screen line when:
// - When outputting a newline.

View File

@ -507,6 +507,8 @@ void update_screen(int type)
maybe_intro_message();
did_intro = TRUE;
// either cmdline is cleared, not drawn or mode is last drawn
cmdline_was_last_drawn = false;
}
/*

View File

@ -4,20 +4,25 @@ local clear, feed = helpers.clear, helpers.feed
local source = helpers.source
local command = helpers.command
local function new_screen(opt)
local screen = Screen.new(25, 5)
screen:attach(opt)
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue1},
[2] = {reverse = true},
[3] = {bold = true, reverse = true},
[4] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
[5] = {bold = true, foreground = Screen.colors.SeaGreen4},
})
return screen
end
local function test_cmdline(linegrid)
local screen
before_each(function()
clear()
screen = Screen.new(25, 5)
screen:attach({rgb=true, ext_cmdline=true, ext_linegrid=linegrid})
screen:set_default_attr_ids({
[1] = {bold = true, foreground = Screen.colors.Blue1},
[2] = {reverse = true},
[3] = {bold = true, reverse = true},
[4] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
[5] = {bold = true, foreground = Screen.colors.SeaGreen4},
})
screen = new_screen({rgb=true, ext_cmdline=true, ext_linegrid=linegrid})
end)
after_each(function()
@ -758,6 +763,57 @@ local function test_cmdline(linegrid)
end
describe('cmdline redraw', function()
local screen
before_each(function()
clear()
screen = new_screen({rgb=true})
end)
after_each(function()
screen:detach()
end)
it('with timer', function()
feed(':012345678901234567890123456789')
screen:expect{grid=[[
|
{1:~ }|
{3: }|
:012345678901234567890123|
456789^ |
]]}
command('call timer_start(0, {-> 1})')
screen:expect{grid=[[
|
{1:~ }|
{3: }|
:012345678901234567890123|
456789^ |
]], unchanged=true, timeout=100}
end)
it('with <Cmd>', function()
command('cmap a <Cmd>0<CR>') -- no-op
feed(':012345678901234567890123456789')
screen:expect{grid=[[
|
{1:~ }|
{3: }|
:012345678901234567890123|
456789^ |
]]}
feed('a')
screen:expect{grid=[[
|
{1:~ }|
{3: }|
:012345678901234567890123|
456789^ |
]], unchanged=true}
end)
end)
-- the representation of cmdline and cmdline_block contents changed with ext_linegrid
-- (which uses indexed highlights) so make sure to test both
describe('ui/ext_cmdline', function() test_cmdline(true) end)