diff options
-rw-r--r-- | src/nvim/ex_docmd.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 7 | ||||
-rw-r--r-- | test/functional/legacy/cmdline_spec.lua | 16 |
3 files changed, 21 insertions, 4 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 8390760b55..534cc6dcfb 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6094,7 +6094,7 @@ static void ex_redrawstatus(exarg_T *eap) } else { status_redraw_curbuf(); } - if (State & MODE_CMDLINE) { + if (msg_scrolled) { return; // redraw later } diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index faf68d038e..9fc92b8f25 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -152,15 +152,20 @@ func Test_redrawstatus_in_autocmd() CheckScreendump let lines =<< trim END - set cmdheight=2 + set laststatus=2 + set statusline=%=:%{getcmdline()} autocmd CmdlineChanged * if getcmdline() == 'foobar' | redrawstatus | endif END call writefile(lines, 'XTest_redrawstatus', 'D') 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, ":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 VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_2', {}) " clean up call term_sendkeys(buf, "\<CR>") diff --git a/test/functional/legacy/cmdline_spec.lua b/test/functional/legacy/cmdline_spec.lua index 8ea5754cfa..8325f7eeb0 100644 --- a/test/functional/legacy/cmdline_spec.lua +++ b/test/functional/legacy/cmdline_spec.lua @@ -178,13 +178,15 @@ describe('cmdline', function() local screen = Screen.new(60, 6) screen:set_default_attr_ids({ [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText - [1] = {bold = true, reverse = true}, -- MsgSeparator + [1] = {bold = true, reverse = true}, -- MsgSeparator, StatusLine }) screen:attach() exec([[ - set cmdheight=2 + set laststatus=2 + set statusline=%=:%{getcmdline()} autocmd CmdlineChanged * if getcmdline() == 'foobar' | redrawstatus | endif ]]) + -- :redrawstatus is postponed if messages have scrolled feed([[:echo "one\ntwo\nthree\nfour"<CR>]]) feed(':foobar') screen:expect([[ @@ -195,6 +197,16 @@ describe('cmdline', function() four | :foobar^ | ]]) + -- it is not postponed if messages have not scrolled + feed('<Esc>:foobar') + screen:expect([[ + | + {0:~ }| + {0:~ }| + {0:~ }| + {1: :foobar}| + :foobar^ | + ]]) end) end) |