Skip to content

Commit 8eeeba8

Browse files
committed
patch 8.0.0678: closing a window does not trigger resizing
Problem: When 'equalalways' is set and closing a window in a separate frame, not all window sizes are adjusted. (Glacambre) Solution: Resize all windows if the new current window is not in the same frame as the closed window. (closes #1707)
1 parent 1814183 commit 8eeeba8

3 files changed

Lines changed: 51 additions & 1 deletion

File tree

src/testdir/test_window_cmd.vim

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,50 @@ func Test_window_width()
318318
bw Xa Xb Xc
319319
endfunc
320320

321+
func Test_equalalways_on_close()
322+
set equalalways
323+
vsplit
324+
windo split
325+
split
326+
wincmd J
327+
" now we have a frame top-left with two windows, a frame top-right with two
328+
" windows and a frame at the bottom, full-width.
329+
let height_1 = winheight(1)
330+
let height_2 = winheight(2)
331+
let height_3 = winheight(3)
332+
let height_4 = winheight(4)
333+
" closing the bottom window causes all windows to be resized.
334+
close
335+
call assert_notequal(height_1, winheight(1))
336+
call assert_notequal(height_2, winheight(2))
337+
call assert_notequal(height_3, winheight(3))
338+
call assert_notequal(height_4, winheight(4))
339+
call assert_equal(winheight(1), winheight(3))
340+
call assert_equal(winheight(2), winheight(4))
341+
342+
1wincmd w
343+
split
344+
4wincmd w
345+
resize + 5
346+
" left column has three windows, equalized heights.
347+
" right column has two windows, top one a bit higher
348+
let height_1 = winheight(1)
349+
let height_2 = winheight(2)
350+
let height_4 = winheight(4)
351+
let height_5 = winheight(5)
352+
3wincmd w
353+
" closing window in left column equalizes heights in left column but not in
354+
" the right column
355+
close
356+
call assert_notequal(height_1, winheight(1))
357+
call assert_notequal(height_2, winheight(2))
358+
call assert_equal(height_4, winheight(3))
359+
call assert_equal(height_5, winheight(4))
360+
361+
only
362+
set equalalways&
363+
endfunc
364+
321365
func Test_window_jump_tag()
322366
help
323367
/iccf

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
678,
767769
/**/
768770
677,
769771
/**/

src/window.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2282,6 +2282,7 @@ win_close(win_T *win, int free_buf)
22822282
int dir;
22832283
int help_window = FALSE;
22842284
tabpage_T *prev_curtab = curtab;
2285+
frame_T *win_frame = win->w_frame;
22852286

22862287
if (last_window())
22872288
{
@@ -2459,7 +2460,10 @@ win_close(win_T *win, int free_buf)
24592460
check_cursor();
24602461
}
24612462
if (p_ea && (*p_ead == 'b' || *p_ead == dir))
2462-
win_equal(curwin, TRUE, dir);
2463+
/* If the frame of the closed window contains the new current window,
2464+
* only resize that frame. Otherwise resize all windows. */
2465+
win_equal(curwin,
2466+
curwin->w_frame->fr_parent == win_frame->fr_parent, dir);
24632467
else
24642468
win_comp_pos();
24652469
if (close_curwin)

0 commit comments

Comments
 (0)