Skip to content

Commit 1c3c104

Browse files
committed
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)
1 parent ae0f30b commit 1c3c104

File tree

5 files changed

+50
-14
lines changed

5 files changed

+50
-14
lines changed

src/option.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -8796,6 +8796,7 @@ set_num_option(
87968796
*/
87978797
if (pp == &p_wh || pp == &p_hh)
87988798
{
8799+
// 'winheight' and 'helpheight'
87998800
if (p_wh < 1)
88008801
{
88018802
errmsg = e_positive;
@@ -8821,10 +8822,9 @@ set_num_option(
88218822
win_setheight((int)p_hh);
88228823
}
88238824
}
8824-
8825-
/* 'winminheight' */
88268825
else if (pp == &p_wmh)
88278826
{
8827+
// 'winminheight'
88288828
if (p_wmh < 0)
88298829
{
88308830
errmsg = e_positive;
@@ -8839,6 +8839,7 @@ set_num_option(
88398839
}
88408840
else if (pp == &p_wiw)
88418841
{
8842+
// 'winwidth'
88428843
if (p_wiw < 1)
88438844
{
88448845
errmsg = e_positive;
@@ -8854,10 +8855,9 @@ set_num_option(
88548855
if (!ONE_WINDOW && curwin->w_width < p_wiw)
88558856
win_setwidth((int)p_wiw);
88568857
}
8857-
8858-
/* 'winminwidth' */
88598858
else if (pp == &p_wmw)
88608859
{
8860+
// 'winminwidth'
88618861
if (p_wmw < 0)
88628862
{
88638863
errmsg = e_positive;
@@ -8868,7 +8868,7 @@ set_num_option(
88688868
errmsg = e_winwidth;
88698869
p_wmw = p_wiw;
88708870
}
8871-
win_setminheight();
8871+
win_setminwidth();
88728872
}
88738873

88748874
/* (re)set last window status line */

src/proto/window.pro

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ void win_setheight_win(int height, win_T *win);
5454
void win_setwidth(int width);
5555
void win_setwidth_win(int width, win_T *wp);
5656
void win_setminheight(void);
57+
void win_setminwidth(void);
5758
void win_drag_status_line(win_T *dragwin, int offset);
5859
void win_drag_vsep_line(win_T *dragwin, int offset);
5960
void set_fraction(win_T *wp);

src/testdir/test_mksession.vim

+10-1
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,22 @@ endfunc
106106

107107
func Test_mksession_winheight()
108108
new
109-
set winheight=10 winminheight=2
109+
set winheight=10
110+
set winminheight=2
110111
mksession! Xtest_mks.out
111112
source Xtest_mks.out
112113

113114
call delete('Xtest_mks.out')
114115
endfunc
115116

117+
func Test_mksession_large_winheight()
118+
set winheight=999
119+
mksession! Xtest_mks_winheight.out
120+
set winheight&
121+
source Xtest_mks_winheight.out
122+
call delete('Xtest_mks_winheight.out')
123+
endfunc
124+
116125
func Test_mksession_arglist()
117126
argdel *
118127
next file1 file2 file3 file4

src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
46,
764766
/**/
765767
45,
766768
/**/

src/window.c

+32-8
Original file line numberDiff line numberDiff line change
@@ -5430,23 +5430,21 @@ frame_setwidth(frame_T *curfrp, int width)
54305430
}
54315431

54325432
/*
5433-
* Check 'winminheight' for a valid value.
5433+
* Check 'winminheight' for a valid value and reduce it if needed.
54345434
*/
54355435
void
54365436
win_setminheight(void)
54375437
{
54385438
int room;
5439+
int needed;
54395440
int first = TRUE;
5440-
win_T *wp;
54415441

5442-
/* loop until there is a 'winminheight' that is possible */
5442+
// loop until there is a 'winminheight' that is possible
54435443
while (p_wmh > 0)
54445444
{
5445-
/* TODO: handle vertical splits */
5446-
room = -p_wh;
5447-
FOR_ALL_WINDOWS(wp)
5448-
room += VISIBLE_HEIGHT(wp) - p_wmh;
5449-
if (room >= 0)
5445+
room = Rows - p_ch;
5446+
needed = frame_minheight(topframe, NULL);
5447+
if (room >= needed)
54505448
break;
54515449
--p_wmh;
54525450
if (first)
@@ -5457,6 +5455,32 @@ win_setminheight(void)
54575455
}
54585456
}
54595457

5458+
/*
5459+
* Check 'winminwidth' for a valid value and reduce it if needed.
5460+
*/
5461+
void
5462+
win_setminwidth(void)
5463+
{
5464+
int room;
5465+
int needed;
5466+
int first = TRUE;
5467+
5468+
// loop until there is a 'winminheight' that is possible
5469+
while (p_wmw > 0)
5470+
{
5471+
room = Columns;
5472+
needed = frame_minwidth(topframe, NULL);
5473+
if (room >= needed)
5474+
break;
5475+
--p_wmw;
5476+
if (first)
5477+
{
5478+
EMSG(_(e_noroom));
5479+
first = FALSE;
5480+
}
5481+
}
5482+
}
5483+
54605484
#if defined(FEAT_MOUSE) || defined(PROTO)
54615485

54625486
/*

0 commit comments

Comments
 (0)