diff src/window.c @ 14057:be8fb2fd51fc v8.1.0046

patch 8.1.0046: loading a session file fails if 'winheight' is big commit https://github.com/vim/vim/commit/1c3c10492a291270fa89b3c8df11828792f927d3 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 12 16:49:30 2018 +0200 patch 8.1.0046: loading a session file fails if 'winheight' is big Problem: Loading a session file fails if 'winheight' is a big number. Solution: Set 'minwinheight' to zero at first. Don't give an error when setting 'minwinheight' while 'winheight' is a big number. Fix using vertical splits. Fix setting 'minwinwidth'. (closes #2970)
author Christian Brabandt <cb@256bit.org>
date Tue, 12 Jun 2018 17:00:07 +0200
parents 3e6477e767ba
children a9d94f10ecef
line wrap: on
line diff
--- a/src/window.c
+++ b/src/window.c
@@ -5430,23 +5430,21 @@ frame_setwidth(frame_T *curfrp, int widt
 }
 
 /*
- * Check 'winminheight' for a valid value.
+ * Check 'winminheight' for a valid value and reduce it if needed.
  */
     void
 win_setminheight(void)
 {
     int		room;
+    int		needed;
     int		first = TRUE;
-    win_T	*wp;
-
-    /* loop until there is a 'winminheight' that is possible */
+
+    // loop until there is a 'winminheight' that is possible
     while (p_wmh > 0)
     {
-	/* TODO: handle vertical splits */
-	room = -p_wh;
-	FOR_ALL_WINDOWS(wp)
-	    room += VISIBLE_HEIGHT(wp) - p_wmh;
-	if (room >= 0)
+	room = Rows - p_ch;
+	needed = frame_minheight(topframe, NULL);
+	if (room >= needed)
 	    break;
 	--p_wmh;
 	if (first)
@@ -5457,6 +5455,32 @@ win_setminheight(void)
     }
 }
 
+/*
+ * Check 'winminwidth' for a valid value and reduce it if needed.
+ */
+    void
+win_setminwidth(void)
+{
+    int		room;
+    int		needed;
+    int		first = TRUE;
+
+    // loop until there is a 'winminheight' that is possible
+    while (p_wmw > 0)
+    {
+	room = Columns;
+	needed = frame_minwidth(topframe, NULL);
+	if (room >= needed)
+	    break;
+	--p_wmw;
+	if (first)
+	{
+	    EMSG(_(e_noroom));
+	    first = FALSE;
+	}
+    }
+}
+
 #if defined(FEAT_MOUSE) || defined(PROTO)
 
 /*