Patch 8.1.2227

11 views
Skip to first unread message

Bram Moolenaar

unread,
Oct 27, 2019, 3:38:49 PM10/27/19
to vim...@googlegroups.com

Patch 8.1.2227
Problem: Layout wrong if 'lines' changes while cmdline window is open.
Solution: Do not restore the window layout if 'lines' changed.
(closes #5130)
Files: src/window.c, src/testdir/test_cmdline.vim,
src/testdir/dumps/Test_cmdwin_restore_1.dump,
src/testdir/dumps/Test_cmdwin_restore_2.dump,
src/testdir/dumps/Test_cmdwin_restore_3.dump


*** ../vim-8.1.2226/src/window.c 2019-10-17 22:58:59.070496999 +0200
--- src/window.c 2019-10-27 20:32:12.013378147 +0100
***************
*** 5177,5193 ****
win_T *wp;

ga_init2(gap, (int)sizeof(int), 1);
! if (ga_grow(gap, win_count() * 2) == OK)
FOR_ALL_WINDOWS(wp)
{
((int *)gap->ga_data)[gap->ga_len++] =
wp->w_width + wp->w_vsep_width;
((int *)gap->ga_data)[gap->ga_len++] = wp->w_height;
}
}

/*
! * Restore window sizes, but only if the number of windows is still the same.
* Does not free the growarray.
*/
void
--- 5177,5199 ----
win_T *wp;

ga_init2(gap, (int)sizeof(int), 1);
! if (ga_grow(gap, win_count() * 2 + 1) == OK)
! {
! // first entry is value of 'lines'
! ((int *)gap->ga_data)[gap->ga_len++] = Rows;
!
FOR_ALL_WINDOWS(wp)
{
((int *)gap->ga_data)[gap->ga_len++] =
wp->w_width + wp->w_vsep_width;
((int *)gap->ga_data)[gap->ga_len++] = wp->w_height;
}
+ }
}

/*
! * Restore window sizes, but only if the number of windows is still the same
! * and 'lines' didn't change.
* Does not free the growarray.
*/
void
***************
*** 5196,5208 ****
win_T *wp;
int i, j;

! if (win_count() * 2 == gap->ga_len)
{
/* The order matters, because frames contain other frames, but it's
* difficult to get right. The easy way out is to do it twice. */
for (j = 0; j < 2; ++j)
{
! i = 0;
FOR_ALL_WINDOWS(wp)
{
frame_setwidth(wp->w_frame, ((int *)gap->ga_data)[i++]);
--- 5202,5215 ----
win_T *wp;
int i, j;

! if (win_count() * 2 + 1 == gap->ga_len
! && ((int *)gap->ga_data)[0] == Rows)
{
/* The order matters, because frames contain other frames, but it's
* difficult to get right. The easy way out is to do it twice. */
for (j = 0; j < 2; ++j)
{
! i = 1;
FOR_ALL_WINDOWS(wp)
{
frame_setwidth(wp->w_frame, ((int *)gap->ga_data)[i++]);
***************
*** 6374,6380 ****
}

/*
! * Return TRUE if there is only one window (in the current tab page), not
* counting a help or preview window, unless it is the current window.
* Does not count unlisted windows.
*/
--- 6381,6387 ----
}

/*
! * Return TRUE if there is only one window and only one tab page, not
* counting a help or preview window, unless it is the current window.
* Does not count unlisted windows.
*/
*** ../vim-8.1.2226/src/testdir/test_cmdline.vim 2019-10-27 05:12:38.284773720 +0100
--- src/testdir/test_cmdline.vim 2019-10-27 20:30:48.077663764 +0100
***************
*** 768,773 ****
--- 768,803 ----
bw!
endfunc

+ func Test_cmdwin_restore()
+ CheckScreendump
+
+ let lines =<< trim [SCRIPT]
+ call setline(1, range(30))
+ 2split
+ [SCRIPT]
+ call writefile(lines, 'XTest_restore')
+
+ let buf = RunVimInTerminal('-S XTest_restore', {'rows': 12})
+ call term_wait(buf, 100)
+ call term_sendkeys(buf, "q:")
+ call VerifyScreenDump(buf, 'Test_cmdwin_restore_1', {})
+
+ " normal restore
+ call term_sendkeys(buf, ":q\<CR>")
+ call VerifyScreenDump(buf, 'Test_cmdwin_restore_2', {})
+
+ " restore after setting 'lines' with one window
+ call term_sendkeys(buf, ":close\<CR>")
+ call term_sendkeys(buf, "q:")
+ call term_sendkeys(buf, ":set lines=18\<CR>")
+ call term_sendkeys(buf, ":q\<CR>")
+ call VerifyScreenDump(buf, 'Test_cmdwin_restore_3', {})
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XTest_restore')
+ endfunc
+
func Test_buffers_lastused()
" check that buffers are sorted by time when wildmode has lastused
call test_settime(1550020000) " middle
*** ../vim-8.1.2226/src/testdir/dumps/Test_cmdwin_restore_1.dump 2019-10-27 20:35:18.344729001 +0100
--- src/testdir/dumps/Test_cmdwin_restore_1.dump 2019-10-27 20:18:24.807814302 +0100
***************
*** 0 ****
--- 1,12 ----
+ |0+0&#ffffff0| @73
+ |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|T|o|p
+ |0+0&&| @73
+ |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|T|o|p
+ |:+0#4040ff13&> +0#0000000&@73
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |[+3#0000000&|C|o|m@1|a|n|d| |L|i|n|e|]| @42|1|,|0|-|1| @9|A|l@1
+ |:+0&&| @73
*** ../vim-8.1.2226/src/testdir/dumps/Test_cmdwin_restore_2.dump 2019-10-27 20:35:18.348728987 +0100
--- src/testdir/dumps/Test_cmdwin_restore_2.dump 2019-10-27 20:18:25.859812073 +0100
***************
*** 0 ****
--- 1,12 ----
+ >0+0&#ffffff0| @73
+ |1| @73
+ |[+3&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|T|o|p
+ |0+0&&| @73
+ |1| @73
+ |2| @73
+ |3| @73
+ |4| @73
+ |5| @73
+ |6| @73
+ |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|1| @11|T|o|p
+ | +0&&@74
*** ../vim-8.1.2226/src/testdir/dumps/Test_cmdwin_restore_3.dump 2019-10-27 20:35:18.352728973 +0100
--- src/testdir/dumps/Test_cmdwin_restore_3.dump 2019-10-27 20:30:55.017640334 +0100
***************
*** 0 ****
--- 1,18 ----
+ >0+0&#ffffff0| @73
+ |1| @73
+ |2| @73
+ |3| @73
+ |4| @73
+ |5| @73
+ |6| @73
+ |7| @73
+ |8| @73
+ |9| @73
+ |1|0| @72
+ |1@1| @72
+ |1|2| @72
+ |1|3| @72
+ |1|4| @72
+ |1|5| @72
+ |1|6| @72
+ @57|1|,|1| @10|T|o|p|
*** ../vim-8.1.2226/src/version.c 2019-10-27 18:50:19.605873781 +0100
--- src/version.c 2019-10-27 20:08:16.777496203 +0100
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 2227,
/**/

--
No engineer can take a shower without wondering if some sort of Teflon coating
would make showering unnecessary.
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Br...@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 ///
Reply all
Reply to author
Forward
0 new messages