summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-03-20 19:55:35 +0100
committerBram Moolenaar <Bram@vim.org>2021-03-20 19:55:35 +0100
commita0c8aea479ca055ce43ba2984a9933f6c48e6161 (patch)
tree23a6911e9f4220af6e1ee0c9578e29dffe31b237
parent592f57f5fec1064cc276a0d7992cc543bed04fd5 (diff)
patch 8.2.2631: commands from winrestcmd() do not always work properlyv8.2.2631
Problem: Commands from winrestcmd() do not always work properly. (Leonid V. Fedorenchik) Solution: Repeat the size commands twice. (closes #7988)
-rw-r--r--src/evalwindow.c21
-rw-r--r--src/testdir/test_window_cmd.vim17
-rw-r--r--src/version.c2
3 files changed, 31 insertions, 9 deletions
diff --git a/src/evalwindow.c b/src/evalwindow.c
index e00747a2de..b1b60d1533 100644
--- a/src/evalwindow.c
+++ b/src/evalwindow.c
@@ -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);
diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim
index 07347a367f..fda34eb463 100644
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -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()
diff --git a/src/version.c b/src/version.c
index a174b28717..420480601e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2631,
+/**/
2630,
/**/
2629,