vim-patch:9.0.0512: cannot redraw the status lines when editing a command

Problem:    Cannot redraw the status lines when editing a command.
Solution:   Only postpone the redraw when messages have scrolled.
            (closes vim/vim#11170)
c14bfc31d9
This commit is contained in:
zeertzjq
2022-09-20 20:54:07 +08:00
parent 9413f7544b
commit 2e4532bea5
3 changed files with 21 additions and 4 deletions

View File

@@ -6094,7 +6094,7 @@ static void ex_redrawstatus(exarg_T *eap)
} else { } else {
status_redraw_curbuf(); status_redraw_curbuf();
} }
if (State & MODE_CMDLINE) { if (msg_scrolled) {
return; // redraw later return; // redraw later
} }

View File

@@ -152,15 +152,20 @@ func Test_redrawstatus_in_autocmd()
CheckScreendump CheckScreendump
let lines =<< trim END let lines =<< trim END
set cmdheight=2 set laststatus=2
set statusline=%=:%{getcmdline()}
autocmd CmdlineChanged * if getcmdline() == 'foobar' | redrawstatus | endif autocmd CmdlineChanged * if getcmdline() == 'foobar' | redrawstatus | endif
END END
call writefile(lines, 'XTest_redrawstatus', 'D') call writefile(lines, 'XTest_redrawstatus', 'D')
let buf = RunVimInTerminal('-S XTest_redrawstatus', {'rows': 8}) let buf = RunVimInTerminal('-S XTest_redrawstatus', {'rows': 8})
" :redrawstatus is postponed if messages have scrolled
call term_sendkeys(buf, ":echo \"one\\ntwo\\nthree\\nfour\"\<CR>") call term_sendkeys(buf, ":echo \"one\\ntwo\\nthree\\nfour\"\<CR>")
call term_sendkeys(buf, ":foobar") call term_sendkeys(buf, ":foobar")
call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_1', {}) call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_1', {})
" it is not postponed if messages have not scrolled
call term_sendkeys(buf, "\<Esc>:foobar")
call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_2', {})
" clean up " clean up
call term_sendkeys(buf, "\<CR>") call term_sendkeys(buf, "\<CR>")

View File

@@ -178,13 +178,15 @@ describe('cmdline', function()
local screen = Screen.new(60, 6) local screen = Screen.new(60, 6)
screen:set_default_attr_ids({ screen:set_default_attr_ids({
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
[1] = {bold = true, reverse = true}, -- MsgSeparator [1] = {bold = true, reverse = true}, -- MsgSeparator, StatusLine
}) })
screen:attach() screen:attach()
exec([[ exec([[
set cmdheight=2 set laststatus=2
set statusline=%=:%{getcmdline()}
autocmd CmdlineChanged * if getcmdline() == 'foobar' | redrawstatus | endif autocmd CmdlineChanged * if getcmdline() == 'foobar' | redrawstatus | endif
]]) ]])
-- :redrawstatus is postponed if messages have scrolled
feed([[:echo "one\ntwo\nthree\nfour"<CR>]]) feed([[:echo "one\ntwo\nthree\nfour"<CR>]])
feed(':foobar') feed(':foobar')
screen:expect([[ screen:expect([[
@@ -195,6 +197,16 @@ describe('cmdline', function()
four | four |
:foobar^ | :foobar^ |
]]) ]])
-- it is not postponed if messages have not scrolled
feed('<Esc>:foobar')
screen:expect([[
|
{0:~ }|
{0:~ }|
{0:~ }|
{1: :foobar}|
:foobar^ |
]])
end) end)
end) end)