patch 9.1.0990: Inconsistent behavior when changing cmdheight
Problem: Inconsistent behavior when changing cmdheight by resizing the
topframe through wincmds and dragging laststatus. Changing
cmdheight by resizing the topframe does not trigger OptionSet.
Solution: Consolidate logic for changing the cmdheight, set the option
value to handle side-effects (Luuk van Baal)
closes: #16359
Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/dumps/Test_changing_cmdheight_1.dump b/src/testdir/dumps/Test_changing_cmdheight_1.dump
index db6d411..127fe26 100644
--- a/src/testdir/dumps/Test_changing_cmdheight_1.dump
+++ b/src/testdir/dumps/Test_changing_cmdheight_1.dump
@@ -5,4 +5,4 @@
| +0&&@74
@75
@75
-|:|r|e|s|i|z|e| |-|3| @64
+@75
diff --git a/src/testdir/dumps/Test_changing_cmdheight_2.dump b/src/testdir/dumps/Test_changing_cmdheight_2.dump
index 76d9440..d652cc6 100644
--- a/src/testdir/dumps/Test_changing_cmdheight_2.dump
+++ b/src/testdir/dumps/Test_changing_cmdheight_2.dump
@@ -1,8 +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
+| +0&&@74
+@75
@75
@75
@75
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index d6f8ef4..5868f1c 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -4902,4 +4902,28 @@
exe "bw! " .. dummy
endfunc
+func Test_OptionSet_cmdheight()
+ set mouse=a laststatus=2
+ au OptionSet cmdheight :let &l:ch = v:option_new
+
+ resize -1
+ call assert_equal(2, &l:ch)
+ resize +1
+ call assert_equal(1, &l:ch)
+
+ call test_setmouse(&lines - 1, 1)
+ call feedkeys("\<LeftMouse>", 'xt')
+ call test_setmouse(&lines - 2, 1)
+ call feedkeys("\<LeftDrag>", 'xt')
+ call assert_equal(2, &l:ch)
+
+ tabnew | resize +1
+ call assert_equal(1, &l:ch)
+ tabfirst
+ call assert_equal(2, &l:ch)
+
+ tabonly
+ set cmdheight& mouse& laststatus&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 6d4fdd7..2b81dc0 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -290,9 +290,10 @@
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>")
+ " :resize now also changes 'cmdheight' accordingly
+ call term_sendkeys(buf, ":set cmdheight+=1\<CR>")
call VerifyScreenDump(buf, 'Test_changing_cmdheight_2', {})
+ call term_sendkeys(buf, ":set cmdheight-=1\<CR>")
" using more space moves the status line up
call term_sendkeys(buf, ":set cmdheight+=1\<CR>")
@@ -311,7 +312,7 @@
call term_sendkeys(buf, ":call EchoTwo()\<CR>")
call VerifyScreenDump(buf, 'Test_changing_cmdheight_6', {})
- " increasing 'cmdheight' doesn't clear the messages that need hit-enter
+ " decreasing 'cmdheight' doesn't clear the messages that need hit-enter
call term_sendkeys(buf, ":call EchoOne()\<CR>")
call VerifyScreenDump(buf, 'Test_changing_cmdheight_7', {})