]> granicus.if.org Git - vim/commitdiff
patch 9.0.0190: the way 'cmdheight' can be made zero is inconsistent v9.0.0190
authorBram Moolenaar <Bram@vim.org>
Thu, 11 Aug 2022 12:17:30 +0000 (13:17 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 11 Aug 2022 12:17:30 +0000 (13:17 +0100)
Problem:    The way 'cmdheight' can be made zero is inconsistent.
Solution:   Only make 'cmdheight' zero when setting it explicitly, not when
            resizing windows. (closes #10890)

src/testdir/dumps/Test_changing_cmdheight_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_changing_cmdheight_2.dump [new file with mode: 0644]
src/testdir/dumps/Test_changing_cmdheight_3.dump [new file with mode: 0644]
src/testdir/dumps/Test_changing_cmdheight_4.dump [new file with mode: 0644]
src/testdir/test_cmdline.vim
src/version.c
src/window.c

diff --git a/src/testdir/dumps/Test_changing_cmdheight_1.dump b/src/testdir/dumps/Test_changing_cmdheight_1.dump
new file mode 100644 (file)
index 0000000..db6d411
--- /dev/null
@@ -0,0 +1,8 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|[+3#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
+| +0&&@74
+@75
+@75
+|:|r|e|s|i|z|e| |-|3| @64
diff --git a/src/testdir/dumps/Test_changing_cmdheight_2.dump b/src/testdir/dumps/Test_changing_cmdheight_2.dump
new file mode 100644 (file)
index 0000000..76d9440
--- /dev/null
@@ -0,0 +1,8 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|[+3#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
+|:+0&&|s|e|t| |c|m|d|h|e|i|g|h|t|+|=|3| @57
+@75
+@75
+@75
diff --git a/src/testdir/dumps/Test_changing_cmdheight_3.dump b/src/testdir/dumps/Test_changing_cmdheight_3.dump
new file mode 100644 (file)
index 0000000..d652cc6
--- /dev/null
@@ -0,0 +1,8 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|[+3#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
+| +0&&@74
+@75
+@75
+@75
+@75
diff --git a/src/testdir/dumps/Test_changing_cmdheight_4.dump b/src/testdir/dumps/Test_changing_cmdheight_4.dump
new file mode 100644 (file)
index 0000000..c4d6fc9
--- /dev/null
@@ -0,0 +1,8 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|[+3#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
+| +0&&@74
+@75
+@75
index 912f3a5d11c0477ad3a625126f3f2ed05c06e212..92adbd10b6b617a8002ff52a534d59e8f8c6795a 100644 (file)
@@ -215,6 +215,35 @@ func Test_redraw_in_autocmd()
   call delete('XTest_redraw')
 endfunc
 
+func Test_changing_cmdheight()
+  CheckScreendump
+
+  let lines =<< trim END
+      set cmdheight=1 laststatus=2
+  END
+  call writefile(lines, 'XTest_cmdheight')
+
+  let buf = RunVimInTerminal('-S XTest_cmdheight', {'rows': 8})
+  call term_sendkeys(buf, ":resize -3\<CR>")
+  call VerifyScreenDump(buf, 'Test_changing_cmdheight_1', {})
+
+  " using the space available doesn't change the status line
+  call term_sendkeys(buf, ":set cmdheight+=3\<CR>")
+  call VerifyScreenDump(buf, 'Test_changing_cmdheight_2', {})
+
+  " using more space moves the status line up
+  call term_sendkeys(buf, ":set cmdheight+=1\<CR>")
+  call VerifyScreenDump(buf, 'Test_changing_cmdheight_3', {})
+
+  " reducing cmdheight moves status line down
+  call term_sendkeys(buf, ":set cmdheight-=2\<CR>")
+  call VerifyScreenDump(buf, 'Test_changing_cmdheight_4', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+  call delete('XTest_cmdheight')
+endfunc
+
 func Test_map_completion()
   call feedkeys(":map <unique> <si\<Tab>\<Home>\"\<CR>", 'xt')
   call assert_equal('"map <unique> <silent>', getreg(':'))
index 03a8091e6ee2881dff8a46bb33d6129d9cfea712..a9887fa62034ad00ceb8840f19e8652ea8cc7a56 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    190,
 /**/
     189,
 /**/
index 2c7bd8edb7151a9a2b40306c2e74b999f963ca8e..5b192cc893fdf6658881754ae3b8c1d83dc2e5a0 100644 (file)
@@ -5702,7 +5702,7 @@ frame_setheight(frame_T *curfrp, int height)
 
     if (curfrp->fr_parent == NULL)
     {
-       // topframe: can only change the command line
+       // topframe: can only change the command line height
        if (height > ROWS_AVAIL)
            // If height is greater than the available space, try to create
            // space for the frame by reducing 'cmdheight' if possible, while
@@ -6089,6 +6089,12 @@ win_drag_status_line(win_T *dragwin, int offset)
     int                row;
     int                up;     // if TRUE, drag status line up, otherwise down
     int                n;
+    static int p_ch_was_zero = FALSE;
+
+    // If the user explicitly set 'cmdheight' to zero, then allow for dragging
+    // the status line making it zero again.
+    if (p_ch == 0)
+       p_ch_was_zero = TRUE;
 
     fr = dragwin->w_frame;
     curfr = fr;
@@ -6147,6 +6153,8 @@ win_drag_status_line(win_T *dragwin, int offset)
        room = Rows - cmdline_row;
        if (curfr->fr_next != NULL)
            room -= p_ch;
+       else if (!p_ch_was_zero)
+           --room;
        if (room < 0)
            room = 0;
        // sum up the room of frames below of the current one
@@ -6196,7 +6204,7 @@ win_drag_status_line(win_T *dragwin, int offset)
     row = win_comp_pos();
     screen_fill(row, cmdline_row, 0, (int)Columns, ' ', ' ', 0);
     cmdline_row = row;
-    p_ch = MAX(Rows - cmdline_row, 0);
+    p_ch = MAX(Rows - cmdline_row, p_ch_was_zero ? 0 : 1);
     curtab->tp_ch_used = p_ch;
     redraw_all_later(SOME_VALID);
     showmode();
@@ -6542,6 +6550,11 @@ command_height(void)
     // p_ch was changed in another tab page.
     curtab->tp_ch_used = p_ch;
 
+    // If the space for the command line is already more than 'cmdheight' there
+    // is nothing to do (window size must have decreased).
+    if (p_ch > old_p_ch && cmdline_row <= Rows - p_ch)
+       return;
+
     // Find bottom frame with width of screen.
     frp = lastwin->w_frame;
     while (frp->fr_width != Columns && frp->fr_parent != NULL)