vim-patch:9.0.0517: when at the command line :redrawstatus does not work well (#20266)

Problem:    When at the command line :redrawstatus does not work well.
Solution:   Only update the statuslines instead of the screen. (closes vim/vim#11180)
320d910064
This commit is contained in:
zeertzjq 2022-09-21 06:47:29 +08:00 committed by GitHub
parent 585ab2564a
commit ad1f353fe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 10 deletions

View File

@ -6094,13 +6094,17 @@ static void ex_redrawstatus(exarg_T *eap)
} else {
status_redraw_curbuf();
}
if (msg_scrolled) {
if (msg_scrolled && (State & MODE_CMDLINE)) {
return; // redraw later
}
RedrawingDisabled = 0;
p_lz = false;
if (State & MODE_CMDLINE) {
redraw_statuslines();
} else {
update_screen(VIsual_active ? UPD_INVERTED : 0);
}
RedrawingDisabled = r;
p_lz = p;
ui_flush();

View File

@ -154,7 +154,7 @@ func Test_redrawstatus_in_autocmd()
let lines =<< trim END
set laststatus=2
set statusline=%=:%{getcmdline()}
autocmd CmdlineChanged * if getcmdline() == 'foobar' | redrawstatus | endif
autocmd CmdlineChanged * redrawstatus
END
call writefile(lines, 'XTest_redrawstatus', 'D')
@ -164,8 +164,17 @@ func Test_redrawstatus_in_autocmd()
call term_sendkeys(buf, ":foobar")
call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_1', {})
" it is not postponed if messages have not scrolled
call term_sendkeys(buf, "\<Esc>:foobar")
call term_sendkeys(buf, "\<Esc>:for in in range(3)")
call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_2', {})
" with cmdheight=1 messages have scrolled when typing :endfor
call term_sendkeys(buf, "\<CR>:endfor")
call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_3', {})
call term_sendkeys(buf, "\<CR>:set cmdheight=2\<CR>")
" with cmdheight=2 messages haven't scrolled when typing :for or :endfor
call term_sendkeys(buf, ":for in in range(3)")
call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_4', {})
call term_sendkeys(buf, "\<CR>:endfor")
call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_5', {})
" clean up
call term_sendkeys(buf, "\<CR>")

View File

@ -175,7 +175,7 @@ describe('cmdline', function()
-- oldtest: Test_redrawstatus_in_autocmd()
it(':redrawstatus in cmdline mode', function()
local screen = Screen.new(60, 6)
local screen = Screen.new(60, 8)
screen:set_default_attr_ids({
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
[1] = {bold = true, reverse = true}, -- MsgSeparator, StatusLine
@ -184,13 +184,16 @@ describe('cmdline', function()
exec([[
set laststatus=2
set statusline=%=:%{getcmdline()}
autocmd CmdlineChanged * if getcmdline() == 'foobar' | redrawstatus | endif
autocmd CmdlineChanged * redrawstatus
set display-=msgsep
]])
-- :redrawstatus is postponed if messages have scrolled
feed([[:echo "one\ntwo\nthree\nfour"<CR>]])
feed(':foobar')
screen:expect([[
{1: }|
{0:~ }|
{0:~ }|
{1: :echo "one\ntwo\nthree\nfour"}|
one |
two |
three |
@ -198,14 +201,52 @@ describe('cmdline', function()
:foobar^ |
]])
-- it is not postponed if messages have not scrolled
feed('<Esc>:foobar')
feed('<Esc>:for in in range(3)')
screen:expect([[
|
{0:~ }|
{0:~ }|
{0:~ }|
{1: :foobar}|
:foobar^ |
{0:~ }|
{0:~ }|
{1: :for in in range(3)}|
:for in in range(3)^ |
]])
-- with cmdheight=1 messages have scrolled when typing :endfor
feed('<CR>:endfor')
screen:expect([[
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{1: :for in in range(3)}|
:for in in range(3) |
: :endfor^ |
]])
feed('<CR>:set cmdheight=2<CR>')
-- with cmdheight=2 messages haven't scrolled when typing :for or :endfor
feed(':for in in range(3)')
screen:expect([[
|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{1: :for in in range(3)}|
:for in in range(3)^ |
|
]])
feed('<CR>:endfor')
screen:expect([[
|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{1: ::endfor}|
:for in in range(3) |
: :endfor^ |
]])
end)
end)