From ad1f353fe1aeb54144a34d1a0de8e318bd5113aa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 21 Sep 2022 06:47:29 +0800 Subject: 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) https://github.com/vim/vim/commit/320d910064320f894a09ffdd1cd800ff5371e97f --- src/nvim/ex_docmd.c | 8 ++++++-- src/nvim/testdir/test_cmdline.vim | 13 +++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 534cc6dcfb..b01a262f84 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -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; - update_screen(VIsual_active ? UPD_INVERTED : 0); + if (State & MODE_CMDLINE) { + redraw_statuslines(); + } else { + update_screen(VIsual_active ? UPD_INVERTED : 0); + } RedrawingDisabled = r; p_lz = p; ui_flush(); diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 9fc92b8f25..60f6930c35 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -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, "\:foobar") + call term_sendkeys(buf, "\: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, "\:endfor") + call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_3', {}) + call term_sendkeys(buf, "\:set cmdheight=2\") + " 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, "\:endfor") + call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_5', {}) " clean up call term_sendkeys(buf, "\") -- cgit