aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/option.c7
-rw-r--r--src/nvim/testdir/test_mksession.vim11
-rw-r--r--src/nvim/window.c41
3 files changed, 45 insertions, 14 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 6eeeca5068..ed9128dbbf 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -4330,19 +4330,26 @@ static char *set_num_option(int opt_idx, char_u *varp, long value,
// Number options that need some action when changed
if (pp == &p_wh) {
+ // 'winheight'
if (!ONE_WINDOW && curwin->w_height < p_wh) {
win_setheight((int)p_wh);
}
} else if (pp == &p_hh) {
+ // 'helpheight'
if (!ONE_WINDOW && curbuf->b_help && curwin->w_height < p_hh) {
win_setheight((int)p_hh);
}
} else if (pp == &p_wmh) {
+ // 'winminheight'
win_setminheight();
} else if (pp == &p_wiw) {
+ // 'winwidth'
if (!ONE_WINDOW && curwin->w_width < p_wiw) {
win_setwidth((int)p_wiw);
}
+ } else if (pp == &p_wmw) {
+ // 'winminwidth'
+ win_setminwidth();
} else if (pp == &p_ls) {
last_status(false); // (re)set last window status line.
} else if (pp == &p_stal) {
diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim
index 0e56ed2ff3..b7169444d1 100644
--- a/src/nvim/testdir/test_mksession.vim
+++ b/src/nvim/testdir/test_mksession.vim
@@ -106,13 +106,22 @@ endfunc
func Test_mksession_winheight()
new
- set winheight=10 winminheight=2
+ set winheight=10
+ set winminheight=2
mksession! Xtest_mks.out
source Xtest_mks.out
call delete('Xtest_mks.out')
endfunc
+func Test_mksession_large_winheight()
+ set winheight=999
+ mksession! Xtest_mks_winheight.out
+ set winheight&
+ source Xtest_mks_winheight.out
+ call delete('Xtest_mks_winheight.out')
+endfunc
+
" Verify that arglist is stored correctly to the session file.
func Test_mksession_arglist()
argdel *
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 0e8cfcedf5..6861e19ca7 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -5229,27 +5229,42 @@ static void frame_setwidth(frame_T *curfrp, int width)
}
}
-/*
- * Check 'winminheight' for a valid value.
- */
+// Check 'winminheight' for a valid value and reduce it if needed.
void win_setminheight(void)
{
- int room;
- int first = TRUE;
+ bool first = true;
- /* 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_IN_TAB(wp, curtab) {
- room += wp->w_height - p_wmh;
+ const int room = Rows - p_ch;
+ const int needed = frame_minheight(topframe, NULL);
+ if (room >= needed) {
+ break;
+ }
+ p_wmh--;
+ if (first) {
+ EMSG(_(e_noroom));
+ first = false;
}
- if (room >= 0)
+ }
+}
+
+// Check 'winminwidth' for a valid value and reduce it if needed.
+void win_setminwidth(void)
+{
+ bool first = true;
+
+ // loop until there is a 'winminheight' that is possible
+ while (p_wmw > 0) {
+ const int room = Columns;
+ const int needed = frame_minwidth(topframe, NULL);
+ if (room >= needed) {
break;
- --p_wmh;
+ }
+ p_wmw--;
if (first) {
EMSG(_(e_noroom));
- first = FALSE;
+ first = false;
}
}
}