changeset 29548:6f9e21c30d7e v9.0.0115

patch 9.0.0115: when 'cmdheight' is zero pressing ':' may scroll a window Commit: https://github.com/vim/vim/commit/6747cf1671bd41cddee77c65b3f9a70509f968db Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 30 19:10:06 2022 +0100 patch 9.0.0115: when 'cmdheight' is zero pressing ':' may scroll a window Problem: When 'cmdheight' is zero pressing ':' may scroll a window. Solution: Add the made_cmdheight_nonzero flag and set 'scrolloff' to zero.
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 Jul 2022 20:15:03 +0200
parents e9f9c092ff10
children ad76819317c8
files src/ex_getln.c src/globals.h src/version.c src/window.c
diffstat 4 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -1615,10 +1615,17 @@ getcmdline_int(
 
     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
@@ -2606,9 +2613,11 @@ theend:
 
 	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;
--- a/src/globals.h
+++ b/src/globals.h
@@ -1728,3 +1728,6 @@ EXTERN int channel_need_redraw INIT(= FA
 // 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);
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    115,
+/**/
     114,
 /**/
     113,
--- a/src/window.c
+++ b/src/window.c
@@ -6365,7 +6365,8 @@ win_new_height(win_T *wp, int height)
 
     // 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);
 }