Skip to content

Commit 415a693

Browse files
committed
patch 8.0.1375: window size wrong after maximizing with WinBar
Problem: Window size wrong after maximizing with WinBar. (Lifepillar) Solution: Fix height computations. Redraw window when it is zero height but has a WinBar. (closes #2356)
1 parent 5fe6bdf commit 415a693

4 files changed

Lines changed: 28 additions & 15 deletions

File tree

src/screen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ win_update(win_T *wp)
11541154
}
11551155

11561156
/* Window is zero-height: nothing to draw. */
1157-
if (wp->w_height == 0)
1157+
if (wp->w_height + WINBAR_HEIGHT(wp) == 0)
11581158
{
11591159
wp->w_redr_type = 0;
11601160
return;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1375,
774776
/**/
775777
1374,
776778
/**/

src/vim.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,8 +1478,10 @@ typedef UINT32_TYPEDEF UINT32_T;
14781478
#define STATUS_HEIGHT 1 /* height of a status line under a window */
14791479
#ifdef FEAT_MENU /* height of a status line under a window */
14801480
# define WINBAR_HEIGHT(wp) (wp)->w_winbar_height
1481+
# define VISIBLE_HEIGHT(wp) ((wp)->w_height + (wp)->w_winbar_height)
14811482
#else
14821483
# define WINBAR_HEIGHT(wp) 0
1484+
# define VISIBLE_HEIGHT(wp) (wp)->w_height
14831485
#endif
14841486
#define QF_WINHEIGHT 10 /* default height for quickfix window */
14851487

src/window.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ win_split_ins(
782782
/* add a status line when p_ls == 1 and splitting the first window */
783783
if (ONE_WINDOW && p_ls == 1 && oldwin->w_status_height == 0)
784784
{
785-
if (oldwin->w_height <= p_wmh && new_wp == NULL)
785+
if (VISIBLE_HEIGHT(oldwin) <= p_wmh && new_wp == NULL)
786786
{
787787
EMSG(_(e_noroom));
788788
return FAIL;
@@ -892,7 +892,7 @@ win_split_ins(
892892
* height.
893893
*/
894894
/* Current window requires at least 1 space. */
895-
wmh1 = (p_wmh == 0 ? 1 : p_wmh);
895+
wmh1 = (p_wmh == 0 ? 1 : p_wmh) + WINBAR_HEIGHT(curwin);
896896
needed = wmh1 + STATUS_HEIGHT;
897897
if (flags & WSP_ROOM)
898898
needed += p_wh - wmh1;
@@ -1105,7 +1105,7 @@ win_split_ins(
11051105
{
11061106
/* height and row of new window is same as current window */
11071107
wp->w_winrow = oldwin->w_winrow;
1108-
win_new_height(wp, oldwin->w_height + WINBAR_HEIGHT(oldwin));
1108+
win_new_height(wp, VISIBLE_HEIGHT(oldwin));
11091109
wp->w_status_height = oldwin->w_status_height;
11101110
}
11111111
frp->fr_height = curfrp->fr_height;
@@ -1180,8 +1180,8 @@ win_split_ins(
11801180
}
11811181
else /* new window below current one */
11821182
{
1183-
wp->w_winrow = oldwin->w_winrow + oldwin->w_height
1184-
+ STATUS_HEIGHT + WINBAR_HEIGHT(oldwin);
1183+
wp->w_winrow = oldwin->w_winrow + VISIBLE_HEIGHT(oldwin)
1184+
+ STATUS_HEIGHT;
11851185
wp->w_status_height = oldwin->w_status_height;
11861186
if (!(flags & WSP_BOT))
11871187
oldwin->w_status_height = STATUS_HEIGHT;
@@ -1422,7 +1422,7 @@ make_windows(
14221422
else
14231423
{
14241424
/* Each window needs at least 'winminheight' lines and a status line. */
1425-
maxcount = (curwin->w_height + curwin->w_status_height
1425+
maxcount = (VISIBLE_HEIGHT(curwin) + curwin->w_status_height
14261426
- (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT);
14271427
}
14281428

@@ -3204,8 +3204,7 @@ frame_fix_width(win_T *wp)
32043204
static void
32053205
frame_fix_height(win_T *wp)
32063206
{
3207-
wp->w_frame->fr_height = wp->w_height + wp->w_status_height
3208-
+ WINBAR_HEIGHT(wp) ;
3207+
wp->w_frame->fr_height = VISIBLE_HEIGHT(wp) + wp->w_status_height;
32093208
}
32103209

32113210
/*
@@ -3230,9 +3229,14 @@ frame_minheight(frame_T *topfrp, win_T *next_curwin)
32303229
{
32313230
/* window: minimal height of the window plus status line */
32323231
m = p_wmh + topfrp->fr_win->w_status_height;
3233-
/* Current window is minimal one line high */
3234-
if (p_wmh == 0 && topfrp->fr_win == curwin && next_curwin == NULL)
3235-
++m;
3232+
if (topfrp->fr_win == curwin && next_curwin == NULL)
3233+
{
3234+
/* Current window is minimal one line high and WinBar is
3235+
* visible. */
3236+
if (p_wmh == 0)
3237+
++m;
3238+
m += WINBAR_HEIGHT(curwin);
3239+
}
32363240
}
32373241
}
32383242
else if (topfrp->fr_layout == FR_ROW)
@@ -4972,6 +4976,7 @@ frame_comp_pos(frame_T *topfrp, int *row, int *col)
49724976
frame_T *frp;
49734977
int startcol;
49744978
int startrow;
4979+
int h;
49754980

49764981
wp = topfrp->fr_win;
49774982
if (wp != NULL)
@@ -4984,7 +4989,9 @@ frame_comp_pos(frame_T *topfrp, int *row, int *col)
49844989
redraw_win_later(wp, NOT_VALID);
49854990
wp->w_redr_status = TRUE;
49864991
}
4987-
*row += wp->w_height + wp->w_status_height;
4992+
/* WinBar will not show if the window height is zero */
4993+
h = VISIBLE_HEIGHT(wp) + wp->w_status_height;
4994+
*row += h > topfrp->fr_height ? topfrp->fr_height : h;
49884995
*col += wp->w_width + wp->w_vsep_width;
49894996
}
49904997
else
@@ -5029,6 +5036,7 @@ win_setheight_win(int height, win_T *win)
50295036
height = p_wmh;
50305037
if (height == 0)
50315038
height = 1;
5039+
height += WINBAR_HEIGHT(curwin);
50325040
}
50335041

50345042
frame_setheight(win->w_frame, height + win->w_status_height);
@@ -5126,7 +5134,8 @@ frame_setheight(frame_T *curfrp, int height)
51265134
else
51275135
{
51285136
room_cmdline = Rows - p_ch - (lastwin->w_winrow
5129-
+ lastwin->w_height + lastwin->w_status_height);
5137+
+ VISIBLE_HEIGHT(lastwin)
5138+
+ lastwin->w_status_height);
51305139
if (room_cmdline < 0)
51315140
room_cmdline = 0;
51325141
}
@@ -5415,7 +5424,7 @@ win_setminheight(void)
54155424
/* TODO: handle vertical splits */
54165425
room = -p_wh;
54175426
FOR_ALL_WINDOWS(wp)
5418-
room += wp->w_height - p_wmh;
5427+
room += VISIBLE_HEIGHT(wp) - p_wmh;
54195428
if (room >= 0)
54205429
break;
54215430
--p_wmh;

0 commit comments

Comments
 (0)