From 7bd4c8e8ee2f623fbde017987f2989e8b8792829 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 19 Sep 2022 12:37:25 +0800 Subject: fix(inccommand): avoid unnecessary redraw when not showing (#20244) --- src/nvim/ex_getln.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e092ea45cf..2a91e9c672 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2385,6 +2385,7 @@ static int command_line_changed(CommandLineState *s) // Trigger CmdlineChanged autocommands. do_autocmd_cmdlinechanged(s->firstc > 0 ? s->firstc : '-'); + const bool prev_cmdpreview = cmdpreview; if (s->firstc == ':' && current_sctx.sc_sid == 0 // only if interactive && *p_icm != NUL // 'inccommand' is set @@ -2393,10 +2394,11 @@ static int command_line_changed(CommandLineState *s) && !vpeekc_any() && cmdpreview_may_show(s)) { // 'inccommand' preview has been shown. - } else if (cmdpreview) { - cmdpreview = false; - update_screen(UPD_SOME_VALID); // Clear 'inccommand' preview. } else { + cmdpreview = false; + if (prev_cmdpreview) { + update_screen(UPD_SOME_VALID); // Clear 'inccommand' preview. + } if (s->xpc.xp_context == EXPAND_NOTHING && (KeyTyped || vpeekc() == NUL)) { may_do_incsearch_highlighting(s->firstc, s->count, &s->is_state); } -- cgit