To: vim_dev@googlegroups.com Subject: Patch 8.2.2631 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2631 Problem: Commands from winrestcmd() do not always work properly. (Leonid V. Fedorenchik) Solution: Repeat the size commands twice. (closes #7988) Files: src/evalwindow.c, src/testdir/test_window_cmd.vim *** ../vim-8.2.2630/src/evalwindow.c 2021-01-12 22:08:50.087871728 +0100 --- src/evalwindow.c 2021-03-20 19:54:40.612552378 +0100 *************** *** 1007,1024 **** f_winrestcmd(typval_T *argvars UNUSED, typval_T *rettv) { win_T *wp; ! int winnr = 1; garray_T ga; char_u buf[50]; ga_init2(&ga, (int)sizeof(char), 70); ! 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); --- 1007,1031 ---- f_winrestcmd(typval_T *argvars UNUSED, typval_T *rettv) { win_T *wp; ! int i; ! int winnr; garray_T ga; char_u buf[50]; 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) ! { ! 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); *** ../vim-8.2.2630/src/testdir/test_window_cmd.vim 2021-01-28 13:47:55.060905101 +0100 --- src/testdir/test_window_cmd.vim 2021-03-20 19:35:48.551895283 +0100 *************** *** 631,646 **** func Test_winrestcmd() 2split 3vsplit ! let a = 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 call assert_equal(2, winheight(0)) call assert_equal(3, winwidth(0)) only endfunc func Fun_RenewFile() --- 631,659 ---- func Test_winrestcmd() 2split 3vsplit ! 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 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() *** ../vim-8.2.2630/src/version.c 2021-03-20 16:44:22.491927605 +0100 --- src/version.c 2021-03-20 19:21:22.578244216 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2631, /**/ -- hundred-and-one symptoms of being an internet addict: 3. Your bookmark takes 15 minutes to scroll from top to bottom. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///