Mercurial > vim
diff src/window.c @ 32826:7c4ad06d80ec v9.0.1726
patch 9.0.1726: incorrect heights in win_size_restore()
Commit: https://github.com/vim/vim/commit/876f5fb570d8401aa4c58af4a5da91f10520aa9d
Author: Sean Dewar <seandewar@users.noreply.github.com>
Date: Thu Aug 17 22:40:05 2023 +0200
patch 9.0.1726: incorrect heights in win_size_restore()
Problem: incorrect heights in win_size_restore()
Solution: avoid restoring incorrect heights in win_size_restore()
Changing 'showtabline' or 'cmdheight' in the cmdwin restores incorrect
window heights after closing the cmdwin.
This may produce a gap between the cmdline and the window above.
Solution: restore window sizes only if the number of lines available for windows
changed; subtract the rows of the tabline, cmdline and last window's statusline
from 'lines' (other statuslines don't matter).
closes: #12704
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Sean Dewar <seandewar@users.noreply.github.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 17 Aug 2023 22:45:06 +0200 |
parents | 80152cf7ce63 |
children | 41482b74f548 |
line wrap: on
line diff
--- a/src/window.c +++ b/src/window.c @@ -5943,7 +5943,6 @@ shell_new_columns(void) */ void win_size_save(garray_T *gap) - { win_T *wp; @@ -5951,8 +5950,8 @@ win_size_save(garray_T *gap) if (ga_grow(gap, win_count() * 2 + 1) == FAIL) return; - // first entry is value of 'lines' - ((int *)gap->ga_data)[gap->ga_len++] = Rows; + // first entry is the total lines available for windows + ((int *)gap->ga_data)[gap->ga_len++] = ROWS_AVAIL - last_stl_height(FALSE); FOR_ALL_WINDOWS(wp) { @@ -5964,7 +5963,7 @@ win_size_save(garray_T *gap) /* * Restore window sizes, but only if the number of windows is still the same - * and 'lines' didn't change. + * and total lines available for windows didn't change. * Does not free the growarray. */ void @@ -5974,7 +5973,7 @@ win_size_restore(garray_T *gap) int i, j; if (win_count() * 2 + 1 == gap->ga_len - && ((int *)gap->ga_data)[0] == Rows) + && ((int *)gap->ga_data)[0] == ROWS_AVAIL - last_stl_height(FALSE)) { // The order matters, because frames contain other frames, but it's // difficult to get right. The easy way out is to do it twice. @@ -7192,8 +7191,7 @@ last_status( int morewin) // pretend there are two or more windows { // Don't make a difference between horizontal or vertical split. - last_status_rec(topframe, (p_ls == 2 - || (p_ls == 1 && (morewin || !ONE_WINDOW)))); + last_status_rec(topframe, last_stl_height(morewin) > 0); } static void @@ -7281,6 +7279,17 @@ tabline_height(void) } /* + * Return the height of the last window's statusline. + */ + int +last_stl_height( + int morewin) // pretend there are two or more windows +{ + return (p_ls == 2 || (p_ls == 1 && (morewin || !ONE_WINDOW))) + ? STATUS_HEIGHT : 0; +} + +/* * Return the minimal number of rows that is needed on the screen to display * the current number of windows. */