Skip to content

Commit a0c8aea

Browse files
committed
patch 8.2.2631: commands from winrestcmd() do not always work properly
Problem: Commands from winrestcmd() do not always work properly. (Leonid V. Fedorenchik) Solution: Repeat the size commands twice. (closes #7988)
1 parent 592f57f commit a0c8aea

3 files changed

Lines changed: 31 additions & 9 deletions

File tree

src/evalwindow.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,18 +1007,25 @@ f_winnr(typval_T *argvars UNUSED, typval_T *rettv)
10071007
f_winrestcmd(typval_T *argvars UNUSED, typval_T *rettv)
10081008
{
10091009
win_T *wp;
1010-
int winnr = 1;
1010+
int i;
1011+
int winnr;
10111012
garray_T ga;
10121013
char_u buf[50];
10131014

10141015
ga_init2(&ga, (int)sizeof(char), 70);
1015-
FOR_ALL_WINDOWS(wp)
1016+
1017+
// Do this twice to handle some window layouts properly.
1018+
for (i = 0; i < 2; ++i)
10161019
{
1017-
sprintf((char *)buf, ":%dresize %d|", winnr, wp->w_height);
1018-
ga_concat(&ga, buf);
1019-
sprintf((char *)buf, "vert :%dresize %d|", winnr, wp->w_width);
1020-
ga_concat(&ga, buf);
1021-
++winnr;
1020+
winnr = 1;
1021+
FOR_ALL_WINDOWS(wp)
1022+
{
1023+
sprintf((char *)buf, ":%dresize %d|", winnr, wp->w_height);
1024+
ga_concat(&ga, buf);
1025+
sprintf((char *)buf, "vert :%dresize %d|", winnr, wp->w_width);
1026+
ga_concat(&ga, buf);
1027+
++winnr;
1028+
}
10221029
}
10231030
ga_append(&ga, NUL);
10241031

src/testdir/test_window_cmd.vim

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,16 +631,29 @@ endfunc
631631
func Test_winrestcmd()
632632
2split
633633
3vsplit
634-
let a = winrestcmd()
634+
let restcmd = winrestcmd()
635635
call assert_equal(2, winheight(0))
636636
call assert_equal(3, winwidth(0))
637637
wincmd =
638638
call assert_notequal(2, winheight(0))
639639
call assert_notequal(3, winwidth(0))
640-
exe a
640+
exe restcmd
641641
call assert_equal(2, winheight(0))
642642
call assert_equal(3, winwidth(0))
643643
only
644+
645+
wincmd v
646+
wincmd s
647+
wincmd v
648+
redraw
649+
let restcmd = winrestcmd()
650+
wincmd _
651+
wincmd |
652+
exe restcmd
653+
redraw
654+
call assert_equal(restcmd, winrestcmd())
655+
656+
only
644657
endfunc
645658

646659
func Fun_RenewFile()

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2631,
753755
/**/
754756
2630,
755757
/**/

0 commit comments

Comments
 (0)