]> granicus.if.org Git - vim/commitdiff
patch 8.1.2227: layout wrong if 'lines' changes while cmdline window is open v8.1.2227
authorBram Moolenaar <Bram@vim.org>
Sun, 27 Oct 2019 19:37:35 +0000 (20:37 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 27 Oct 2019 19:37:35 +0000 (20:37 +0100)
Problem:    Layout wrong if 'lines' changes while cmdline window is open.
Solution:   Do not restore the window layout if 'lines' changed.
            (closes #5130)

src/testdir/dumps/Test_cmdwin_restore_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_cmdwin_restore_2.dump [new file with mode: 0644]
src/testdir/dumps/Test_cmdwin_restore_3.dump [new file with mode: 0644]
src/testdir/test_cmdline.vim
src/version.c
src/window.c

diff --git a/src/testdir/dumps/Test_cmdwin_restore_1.dump b/src/testdir/dumps/Test_cmdwin_restore_1.dump
new file mode 100644 (file)
index 0000000..8ac0295
--- /dev/null
@@ -0,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
diff --git a/src/testdir/dumps/Test_cmdwin_restore_2.dump b/src/testdir/dumps/Test_cmdwin_restore_2.dump
new file mode 100644 (file)
index 0000000..ce0b2b5
--- /dev/null
@@ -0,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
diff --git a/src/testdir/dumps/Test_cmdwin_restore_3.dump b/src/testdir/dumps/Test_cmdwin_restore_3.dump
new file mode 100644 (file)
index 0000000..1cc0f3f
--- /dev/null
@@ -0,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| 
index 57dff4167316b3b4bf6a61562e47b57c0ff74090..3f73d3da34950d8a4cfc1c5091b0db913faf75dc 100644 (file)
@@ -768,6 +768,36 @@ func Test_cmdwin_bug()
   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
index f5bc809acadb3c41b035ea46af8fb60173646225..7b4ebe6b561bedbaed49c47053a5cbdeff6da384 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2227,
 /**/
     2226,
 /**/
index 8bb3269a0f514bbae4d4f48adf049416bccb26ea..abdbd507969afc28fed38cfa7de648f83f102e0c 100644 (file)
@@ -5177,17 +5177,23 @@ win_size_save(garray_T *gap)
     win_T      *wp;
 
     ga_init2(gap, (int)sizeof(int), 1);
-    if (ga_grow(gap, win_count() * 2) == OK)
+    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.
+ * 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,13 +5202,14 @@ win_size_restore(garray_T *gap)
     win_T      *wp;
     int                i, j;
 
-    if (win_count() * 2 == gap->ga_len)
+    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 = 0;
+           i = 1;
            FOR_ALL_WINDOWS(wp)
            {
                frame_setwidth(wp->w_frame, ((int *)gap->ga_data)[i++]);
@@ -6374,7 +6381,7 @@ min_rows(void)
 }
 
 /*
- * Return TRUE if there is only one window (in the current tab page), not
+ * 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.
  */