mirror of
https://github.com/neovim/neovim.git
synced 2025-10-04 17:06:30 +00:00
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)
a0c8aea479
This commit is contained in:
@@ -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)
|
static void f_winrestcmd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
int winnr = 1;
|
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
char_u buf[50];
|
char_u buf[50];
|
||||||
|
|
||||||
ga_init(&ga, (int)sizeof(char), 70);
|
ga_init(&ga, (int)sizeof(char), 70);
|
||||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
|
||||||
sprintf((char *)buf, "%dresize %d|", winnr, wp->w_height);
|
// Do this twice to handle some window layouts properly.
|
||||||
ga_concat(&ga, buf);
|
for (int i = 0; i < 2; i++) {
|
||||||
sprintf((char *)buf, "vert %dresize %d|", winnr, wp->w_width);
|
int winnr = 1;
|
||||||
ga_concat(&ga, buf);
|
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||||
++winnr;
|
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);
|
ga_append(&ga, NUL);
|
||||||
|
|
||||||
|
@@ -550,16 +550,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
|
||||||
|
|
||||||
function! Fun_RenewFile()
|
function! Fun_RenewFile()
|
||||||
|
Reference in New Issue
Block a user