aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r--src/nvim/window.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index ad1e1f8f02..00f49724b6 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -4540,7 +4540,7 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid,
// Might need to scroll the old window before switching, e.g., when the
// cursor was moved.
- update_topline();
+ update_topline(curwin);
// may have to copy the buffer options when 'cpo' contains 'S'
if (wp->w_buffer != curbuf) {
@@ -5013,7 +5013,10 @@ void win_size_save(garray_T *gap)
{
ga_init(gap, (int)sizeof(int), 1);
- ga_grow(gap, win_count() * 2);
+ ga_grow(gap, win_count() * 2 + 1);
+ // first entry is value of 'lines'
+ ((int *)gap->ga_data)[gap->ga_len++] = Rows;
+
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
((int *)gap->ga_data)[gap->ga_len++] =
wp->w_width + wp->w_vsep_width;
@@ -5021,18 +5024,18 @@ void win_size_save(garray_T *gap)
}
}
-/*
- * Restore window sizes, but only if the number of windows is still the same.
- * Does not free the growarray.
- */
+// Restore window sizes, but only if the number of windows is still the same
+// and 'lines' didn't change.
+// Does not free the growarray.
void win_size_restore(garray_T *gap)
+ FUNC_ATTR_NONNULL_ALL
{
- if (win_count() * 2 == gap->ga_len) {
- /* The order matters, because frames contain other frames, but it's
- * difficult to get right. The easy way out is to do it twice. */
- for (int j = 0; j < 2; ++j)
- {
- int i = 0;
+ if (win_count() * 2 + 1 == gap->ga_len
+ && ((int *)gap->ga_data)[0] == Rows) {
+ // The order matters, because frames contain other frames, but it's
+ // difficult to get right. The easy way out is to do it twice.
+ for (int j = 0; j < 2; j++) {
+ int i = 1;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
int width = ((int *)gap->ga_data)[i++];
int height = ((int *)gap->ga_data)[i++];
@@ -5346,6 +5349,8 @@ void win_setwidth_win(int width, win_T *wp)
width = p_wmw;
if (width == 0)
width = 1;
+ } else if (width < 0) {
+ width = 0;
}
if (wp->w_floating) {
wp->w_float_config.width = width;
@@ -5873,10 +5878,10 @@ void scroll_to_fraction(win_T *wp, int prev_height)
}
if (wp == curwin) {
- if (get_scrolloff_value()) {
- update_topline();
+ if (get_scrolloff_value(wp)) {
+ update_topline(wp);
}
- curs_columns(false); // validate w_wrow
+ curs_columns(wp, false); // validate w_wrow
}
if (prev_height > 0) {
wp->w_prev_fraction_row = wp->w_wrow;
@@ -5932,8 +5937,8 @@ void win_set_inner_size(win_T *wp)
changed_line_abv_curs_win(wp);
invalidate_botline_win(wp);
if (wp == curwin) {
- update_topline();
- curs_columns(true); // validate w_wrow
+ update_topline(wp);
+ curs_columns(wp, true); // validate w_wrow
}
redraw_later(wp, NOT_VALID);
}