if (cmdheight0)
{
- // If cmdheight is 0, cmdheight must be set to 1 when we enter command
- // line.
+ int save_so = lastwin->w_p_so;
+
+ // If cmdheight is 0, cmdheight must be set to 1 when we enter the
+ // command line. Set "made_cmdheight_nonzero" and reset 'scrolloff' to
+ // avoid scrolling the last window.
+ made_cmdheight_nonzero = TRUE;
+ lastwin->w_p_so = 0;
set_option_value((char_u *)"ch", 1L, NULL, 0);
update_screen(VALID); // redraw the screen NOW
+ made_cmdheight_nonzero = FALSE;
+ lastwin->w_p_so = save_so;
}
// one recursion level deeper
if (cmdheight0)
{
+ made_cmdheight_nonzero = TRUE;
set_option_value((char_u *)"ch", 0L, NULL, 0);
// Redraw is needed for command line completion
redraw_all_later(CLEAR);
+ made_cmdheight_nonzero = FALSE;
}
--depth;
// While executing a regexp and set to OPTION_MAGIC_ON or OPTION_MAGIC_OFF this
// overrules p_magic. Otherwise set to OPTION_MAGIC_NOT_SET.
EXTERN optmagic_T magic_overruled INIT(= OPTION_MAGIC_NOT_SET);
+
+// Set when 'cmdheight' is changed from non-zero to one temporarily.
+EXTERN int made_cmdheight_nonzero INIT(= FALSE);
// There is no point in adjusting the scroll position when exiting. Some
// values might be invalid.
- if (!exiting)
+ // Skip scroll_to_fraction() when 'cmdheight' was set to one from zero.
+ if (!exiting && !made_cmdheight_nonzero)
scroll_to_fraction(wp, prev_height);
}