Skip to content

Commit

Permalink
fix(ui): make window resize commands manage cmdheight
Browse files Browse the repository at this point in the history
Previously, the window resize commands did not resize the value of `cmdheight` when they caused a change in the topframe height, leaving a gap between the end of topframe and the start of the command line, this commit fixes that by making window resize commands automatically change the value of cmdheight if the resize affects the height of topframe.
  • Loading branch information
famiu authored and bfredl committed Apr 5, 2022
1 parent b08cf73 commit 463174b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/nvim/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -5412,11 +5412,17 @@ void win_setheight_win(int height, win_T *win)
// line, clear it.
if (full_screen && msg_scrolled == 0 && row < cmdline_row) {
grid_fill(&default_grid, row, cmdline_row, 0, Columns, ' ', ' ', 0);
if (msg_grid.chars) {
clear_cmdline = true;
}
}
cmdline_row = row;
p_ch = MAX(Rows - cmdline_row, 1);
curtab->tp_ch_used = p_ch;
msg_row = row;
msg_col = 0;
redraw_all_later(NOT_VALID);
showmode();
}
}

Expand Down Expand Up @@ -5452,7 +5458,9 @@ static void frame_setheight(frame_T *curfrp, int height)
if (curfrp->fr_parent == NULL) {
// topframe: can only change the command line
if (height > ROWS_AVAIL) {
height = ROWS_AVAIL;
// If height is greater than the available space, try to create space for the frame by
// reducing 'cmdheight' if possible, while making sure `cmdheight` doesn't go below 1.
height = MIN(ROWS_AVAIL + (p_ch - 1), height);
}
if (height > 0) {
frame_new_height(curfrp, height, false, false);
Expand Down
4 changes: 2 additions & 2 deletions test/functional/legacy/cmdline_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ describe('cmdline', function()
~ |
~ |
~ |
6 |
7 |
|
|
|
]])
end)
Expand Down

0 comments on commit 463174b

Please sign in to comment.