diff options
Diffstat (limited to 'src/window.c')
-rw-r--r-- | src/window.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/window.c b/src/window.c index 00b35bbbbf..fbdad9c2a2 100644 --- a/src/window.c +++ b/src/window.c @@ -896,8 +896,8 @@ cmd_with_count( } /* - * If "split_disallowed" is set for "wp", give an error and return FAIL. - * Otherwise return OK. + * If "split_disallowed" is set, or "wp"'s buffer is closing, give an error and + * return FAIL. Otherwise return OK. */ int check_split_disallowed(win_T *wp) @@ -1980,7 +1980,6 @@ win_splitmove(win_T *wp, int size, int flags) // existing window, so just undo winframe_remove. winframe_restore(wp, dir, unflat_altfr); win_append(wp->w_prev, wp); - (void)win_comp_pos(); // recompute window positions return FAIL; } @@ -3607,7 +3606,6 @@ winframe_remove( * Flatten "frp" into its parent frame if it's the only child, also merging its * list with the grandparent if they share the same layout. * Frees "frp" if flattened; also "frp->fr_parent" if it has the same layout. - * "frp" must be valid in the current tabpage. */ static void frame_flatten(frame_T *frp) @@ -3660,13 +3658,16 @@ frame_flatten(frame_T *frp) /* * Undo changes from a prior call to winframe_remove, also restoring lost - * vertical separators and statuslines. + * vertical separators and statuslines, and changed window positions for + * windows within "unflat_altfr". * Caller must ensure no other changes were made to the layout or window sizes! */ static void winframe_restore(win_T *wp, int dir, frame_T *unflat_altfr) { frame_T *frp = wp->w_frame; + int row = wp->w_winrow; + int col = wp->w_wincol; // Put "wp"'s frame back where it was. if (frp->fr_prev != NULL) @@ -3684,17 +3685,25 @@ winframe_restore(win_T *wp, int dir, frame_T *unflat_altfr) && frp->fr_parent->fr_layout == FR_COL && frp->fr_prev != NULL) frame_add_statusline(frp->fr_prev); - // Restore the lost room that was redistributed to the altframe. + // Restore the lost room that was redistributed to the altframe. Also + // adjusts window sizes to fit restored statuslines/separators, if needed. if (dir == 'v') { frame_new_height(unflat_altfr, unflat_altfr->fr_height - frp->fr_height, unflat_altfr == frp->fr_next, FALSE); + row += frp->fr_height; } else if (dir == 'h') { frame_new_width(unflat_altfr, unflat_altfr->fr_width - frp->fr_width, unflat_altfr == frp->fr_next, FALSE); + col += frp->fr_width; } + + // If rows/columns went to a window below/right, its positions need to be + // restored. Can only be done after the sizes have been updated. + if (unflat_altfr == frp->fr_next) + frame_comp_pos(unflat_altfr, &row, &col); } /* |