]> granicus.if.org Git - vim/commitdiff
patch 8.2.2631: commands from winrestcmd() do not always work properly v8.2.2631
authorBram Moolenaar <Bram@vim.org>
Sat, 20 Mar 2021 18:55:35 +0000 (19:55 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 20 Mar 2021 18:55:35 +0000 (19:55 +0100)
Problem:    Commands from winrestcmd() do not always work properly. (Leonid V.
            Fedorenchik)
Solution:   Repeat the size commands twice. (closes #7988)

src/evalwindow.c
src/testdir/test_window_cmd.vim
src/version.c

index e00747a2de56a78749dbd72a067c284f2935554d..b1b60d15338c57e2b4e8c383b0a19f0b8b244e79 100644 (file)
@@ -1007,18 +1007,25 @@ f_winnr(typval_T *argvars UNUSED, typval_T *rettv)
 f_winrestcmd(typval_T *argvars UNUSED, typval_T *rettv)
 {
     win_T      *wp;
-    int                winnr = 1;
+    int                i;
+    int                winnr;
     garray_T   ga;
     char_u     buf[50];
 
     ga_init2(&ga, (int)sizeof(char), 70);
-    FOR_ALL_WINDOWS(wp)
+
+    // Do this twice to handle some window layouts properly.
+    for (i = 0; i < 2; ++i)
     {
-       sprintf((char *)buf, ":%dresize %d|", winnr, wp->w_height);
-       ga_concat(&ga, buf);
-       sprintf((char *)buf, "vert :%dresize %d|", winnr, wp->w_width);
-       ga_concat(&ga, buf);
-       ++winnr;
+       winnr = 1;
+       FOR_ALL_WINDOWS(wp)
+       {
+           sprintf((char *)buf, ":%dresize %d|", winnr, wp->w_height);
+           ga_concat(&ga, buf);
+           sprintf((char *)buf, "vert :%dresize %d|", winnr, wp->w_width);
+           ga_concat(&ga, buf);
+           ++winnr;
+       }
     }
     ga_append(&ga, NUL);
 
index 07347a367f577e4c905fdf12f656531e98b4dde6..fda34eb4635f9fd1769e387b7595a5c4c0f9c0ee 100644 (file)
@@ -631,16 +631,29 @@ endfunc
 func Test_winrestcmd()
   2split
   3vsplit
-  let a = winrestcmd()
+  let restcmd = winrestcmd()
   call assert_equal(2, winheight(0))
   call assert_equal(3, winwidth(0))
   wincmd =
   call assert_notequal(2, winheight(0))
   call assert_notequal(3, winwidth(0))
-  exe a
+  exe restcmd
   call assert_equal(2, winheight(0))
   call assert_equal(3, winwidth(0))
   only
+
+  wincmd v
+  wincmd s
+  wincmd v
+  redraw
+  let restcmd = winrestcmd()
+  wincmd _
+  wincmd |
+  exe restcmd
+  redraw
+  call assert_equal(restcmd, winrestcmd())
+
+  only
 endfunc
 
 func Fun_RenewFile()
index a174b2871718cce3b2e208d0469fac17f3476433..420480601ed217fbaa6cb647fc24feade05d3cb3 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2631,
 /**/
     2630,
 /**/