mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
vim-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 vim/vim#2970)
1c3c10492a
This commit is contained in:
@@ -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
|
// Number options that need some action when changed
|
||||||
if (pp == &p_wh) {
|
if (pp == &p_wh) {
|
||||||
|
// 'winheight'
|
||||||
if (!ONE_WINDOW && curwin->w_height < p_wh) {
|
if (!ONE_WINDOW && curwin->w_height < p_wh) {
|
||||||
win_setheight((int)p_wh);
|
win_setheight((int)p_wh);
|
||||||
}
|
}
|
||||||
} else if (pp == &p_hh) {
|
} else if (pp == &p_hh) {
|
||||||
|
// 'helpheight'
|
||||||
if (!ONE_WINDOW && curbuf->b_help && curwin->w_height < p_hh) {
|
if (!ONE_WINDOW && curbuf->b_help && curwin->w_height < p_hh) {
|
||||||
win_setheight((int)p_hh);
|
win_setheight((int)p_hh);
|
||||||
}
|
}
|
||||||
} else if (pp == &p_wmh) {
|
} else if (pp == &p_wmh) {
|
||||||
|
// 'winminheight'
|
||||||
win_setminheight();
|
win_setminheight();
|
||||||
} else if (pp == &p_wiw) {
|
} else if (pp == &p_wiw) {
|
||||||
|
// 'winwidth'
|
||||||
if (!ONE_WINDOW && curwin->w_width < p_wiw) {
|
if (!ONE_WINDOW && curwin->w_width < p_wiw) {
|
||||||
win_setwidth((int)p_wiw);
|
win_setwidth((int)p_wiw);
|
||||||
}
|
}
|
||||||
|
} else if (pp == &p_wmw) {
|
||||||
|
// 'winminwidth'
|
||||||
|
win_setminwidth();
|
||||||
} else if (pp == &p_ls) {
|
} else if (pp == &p_ls) {
|
||||||
last_status(false); // (re)set last window status line.
|
last_status(false); // (re)set last window status line.
|
||||||
} else if (pp == &p_stal) {
|
} else if (pp == &p_stal) {
|
||||||
|
@@ -106,13 +106,22 @@ endfunc
|
|||||||
|
|
||||||
func Test_mksession_winheight()
|
func Test_mksession_winheight()
|
||||||
new
|
new
|
||||||
set winheight=10 winminheight=2
|
set winheight=10
|
||||||
|
set winminheight=2
|
||||||
mksession! Xtest_mks.out
|
mksession! Xtest_mks.out
|
||||||
source Xtest_mks.out
|
source Xtest_mks.out
|
||||||
|
|
||||||
call delete('Xtest_mks.out')
|
call delete('Xtest_mks.out')
|
||||||
endfunc
|
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.
|
" Verify that arglist is stored correctly to the session file.
|
||||||
func Test_mksession_arglist()
|
func Test_mksession_arglist()
|
||||||
argdel *
|
argdel *
|
||||||
|
@@ -5229,27 +5229,42 @@ static void frame_setwidth(frame_T *curfrp, int width)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Check 'winminheight' for a valid value and reduce it if needed.
|
||||||
* Check 'winminheight' for a valid value.
|
|
||||||
*/
|
|
||||||
void win_setminheight(void)
|
void win_setminheight(void)
|
||||||
{
|
{
|
||||||
int room;
|
bool first = true;
|
||||||
int first = TRUE;
|
|
||||||
|
|
||||||
/* loop until there is a 'winminheight' that is possible */
|
// loop until there is a 'winminheight' that is possible
|
||||||
while (p_wmh > 0) {
|
while (p_wmh > 0) {
|
||||||
/* TODO: handle vertical splits */
|
const int room = Rows - p_ch;
|
||||||
room = -p_wh;
|
const int needed = frame_minheight(topframe, NULL);
|
||||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
if (room >= needed) {
|
||||||
room += wp->w_height - p_wmh;
|
|
||||||
}
|
|
||||||
if (room >= 0)
|
|
||||||
break;
|
break;
|
||||||
--p_wmh;
|
}
|
||||||
|
p_wmh--;
|
||||||
if (first) {
|
if (first) {
|
||||||
EMSG(_(e_noroom));
|
EMSG(_(e_noroom));
|
||||||
first = FALSE;
|
first = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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_wmw--;
|
||||||
|
if (first) {
|
||||||
|
EMSG(_(e_noroom));
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user