diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-03-20 23:18:40 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-03-21 00:26:42 -0400 |
commit | 749a8b6be767ee3e4dfd83af72973b386ac5ead1 (patch) | |
tree | b40060f352ecf809aa42e455f5998c39c9bdff82 /src/nvim/eval/funcs.c | |
parent | 0bf9f10da08d4eaf3e7957136a6bfb9e505720b8 (diff) | |
download | rneovim-749a8b6be767ee3e4dfd83af72973b386ac5ead1.tar.gz rneovim-749a8b6be767ee3e4dfd83af72973b386ac5ead1.tar.bz2 rneovim-749a8b6be767ee3e4dfd83af72973b386ac5ead1.zip |
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 vim/vim#7988)
https://github.com/vim/vim/commit/a0c8aea479ca055ce43ba2984a9933f6c48e6161
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r-- | src/nvim/eval/funcs.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 9edf5c8f7e..6304a3d191 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -11378,17 +11378,23 @@ static void f_winnr(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ static void f_winrestcmd(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - int winnr = 1; garray_T ga; char_u buf[50]; ga_init(&ga, (int)sizeof(char), 70); - FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { - 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; + + // Do this twice to handle some window layouts properly. + for (int i = 0; i < 2; i++) { + int winnr = 1; + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { + snprintf((char *)buf, sizeof(buf), "%dresize %d|", winnr, + wp->w_height); + ga_concat(&ga, buf); + snprintf((char *)buf, sizeof(buf), "vert %dresize %d|", winnr, + wp->w_width); + ga_concat(&ga, buf); + winnr++; + } } ga_append(&ga, NUL); |