patch 9.1.0855: setting 'cmdheight' may cause hit-enter-prompt

Problem:  setting 'cmdheight' may cause hit-enter-prompt and echo output
          to be missing
Solution: Before cleaning the cmdline, check the need_wait_return flag
          (nwounkn)

closes: #13432

Signed-off-by: nwounkn <nwounkn@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 30ded35..110be65 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -270,6 +270,12 @@
 
   let lines =<< trim END
       set cmdheight=1 laststatus=2
+      func EchoOne()
+        set laststatus=2 cmdheight=1
+        echo 'foo'
+        echo 'bar'
+        set cmdheight=2
+      endfunc
       func EchoTwo()
         set laststatus=2
         set cmdheight=5
@@ -305,6 +311,10 @@
   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
+  call term_sendkeys(buf, ":call EchoOne()\<CR>")
+  call VerifyScreenDump(buf, 'Test_changing_cmdheight_7', {})
+
   " clean up
   call StopVimInTerminal(buf)
 endfunc