1
0
forked from aniani/vim

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)
This commit is contained in:
Bram Moolenaar
2021-03-20 19:55:35 +01:00
parent 592f57f5fe
commit a0c8aea479
3 changed files with 31 additions and 9 deletions

View File

@@ -1007,11 +1007,17 @@ f_winnr(typval_T *argvars UNUSED, typval_T *rettv)
f_winrestcmd(typval_T *argvars UNUSED, typval_T *rettv) f_winrestcmd(typval_T *argvars UNUSED, typval_T *rettv)
{ {
win_T *wp; win_T *wp;
int winnr = 1; int i;
int winnr;
garray_T ga; garray_T ga;
char_u buf[50]; char_u buf[50];
ga_init2(&ga, (int)sizeof(char), 70); ga_init2(&ga, (int)sizeof(char), 70);
// Do this twice to handle some window layouts properly.
for (i = 0; i < 2; ++i)
{
winnr = 1;
FOR_ALL_WINDOWS(wp) FOR_ALL_WINDOWS(wp)
{ {
sprintf((char *)buf, ":%dresize %d|", winnr, wp->w_height); sprintf((char *)buf, ":%dresize %d|", winnr, wp->w_height);
@@ -1020,6 +1026,7 @@ f_winrestcmd(typval_T *argvars UNUSED, typval_T *rettv)
ga_concat(&ga, buf); ga_concat(&ga, buf);
++winnr; ++winnr;
} }
}
ga_append(&ga, NUL); ga_append(&ga, NUL);
rettv->vval.v_string = ga.ga_data; rettv->vval.v_string = ga.ga_data;

View File

@@ -631,16 +631,29 @@ endfunc
func Test_winrestcmd() func Test_winrestcmd()
2split 2split
3vsplit 3vsplit
let a = winrestcmd() let restcmd = winrestcmd()
call assert_equal(2, winheight(0)) call assert_equal(2, winheight(0))
call assert_equal(3, winwidth(0)) call assert_equal(3, winwidth(0))
wincmd = wincmd =
call assert_notequal(2, winheight(0)) call assert_notequal(2, winheight(0))
call assert_notequal(3, winwidth(0)) call assert_notequal(3, winwidth(0))
exe a exe restcmd
call assert_equal(2, winheight(0)) call assert_equal(2, winheight(0))
call assert_equal(3, winwidth(0)) call assert_equal(3, winwidth(0))
only only
wincmd v
wincmd s
wincmd v
redraw
let restcmd = winrestcmd()
wincmd _
wincmd |
exe restcmd
redraw
call assert_equal(restcmd, winrestcmd())
only
endfunc endfunc
func Fun_RenewFile() func Fun_RenewFile()

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2631,
/**/ /**/
2630, 2630,
/**/ /**/