Reuse inccommand preview window (fix #11529) (#12612)

* Reuse inccommand preview window

Currently, show_sub (inside ex_substitute) creates a new split on each
run for its existing buffer, and ex_substitute calls close_windows for
it. This functionality seems to relay in delayed operations on window
structures where the close event on the newest window is "cancelled" by
win_grid_alloc. But for multigrid, there is optimization in place in
win_grid_alloc which causes any (unnecessary?) allocations to be
skipped, and thus inccommand preview window is not preserved but closed
immediately. Alternative fix would be to remove said optimization, but
the whole "lets create a new split each time and trash the earlier
window" seems too wasteful.

Fix #11529

* Update failing test

The failing test sets inccommand=split and does `:%s/.`, but isn't
expecting to get any contents for the preview window, other than the
windows status line. Update the test to include the preview window
contents too.
This commit is contained in:
Ville Hakulinen
2020-07-15 15:46:47 +03:00
committed by GitHub
parent 1ca67a73c0
commit a02a267f8a
3 changed files with 64 additions and 20 deletions

View File

@@ -450,6 +450,11 @@ static uint8_t *command_line_enter(int firstc, long count, int indent)
ExpandCleanup(&s->xpc);
ccline.xpc = NULL;
if (s->gotesc) {
// There might be a preview window open for inccommand. Close it.
close_preview_windows();
}
if (s->did_incsearch) {
if (s->gotesc) {
curwin->w_cursor = s->save_cursor;
@@ -1958,8 +1963,10 @@ static int command_line_changed(CommandLineState *s)
update_topline();
redrawcmdline();
} else if (State & CMDPREVIEW) {
State = (State & ~CMDPREVIEW);
close_preview_windows();
update_screen(SOME_VALID); // Clear 'inccommand' preview.
}