patch 9.0.1195: restoring KeyTyped when building statusline not tested

Problem:    Restoring KeyTyped when building statusline not tested.
Solution:   Add a test.  Clean up and fix other tests. (closes #11815)
diff --git a/src/globals.h b/src/globals.h
index 8c3cb62..e38b471 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -2043,6 +2043,6 @@
 // Skip update_topline() call while executing win_fix_scroll().
 EXTERN int skip_update_topline INIT(= FALSE);
 
-// 'showcmd' buffer shared between normal.c and statusline.c
+// 'showcmd' buffer shared between normal.c and statusline code
 #define SHOWCMD_BUFLEN (SHOWCMD_COLS + 1 + 30)
 EXTERN char_u showcmd_buf[SHOWCMD_BUFLEN];
diff --git a/src/testdir/dumps/Test_statusline_showcmd_1.dump b/src/testdir/dumps/Test_statusline_showcmd_1.dump
index 049e0f7..626f60b 100644
--- a/src/testdir/dumps/Test_statusline_showcmd_1.dump
+++ b/src/testdir/dumps/Test_statusline_showcmd_1.dump
@@ -1,6 +1,6 @@
-|a+0&#e0e0e08| +0&#ffffff0@73
-|b+0&#e0e0e08| +0&#ffffff0@73
-|c+0&#e0e0e08> +0&#ffffff0@73
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |a|-@59
+>c+0#0000000#ffffff0| @73
 |~+0#4040ff13&| @73
-|3+3#0000000&|x|2| @71
-|-+2&&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@56
+|~| @73
+|g+3#0000000&| @73
+| +0&&@74
diff --git a/src/testdir/dumps/Test_statusline_showcmd_2.dump b/src/testdir/dumps/Test_statusline_showcmd_2.dump
index c443662..2844f12 100644
--- a/src/testdir/dumps/Test_statusline_showcmd_2.dump
+++ b/src/testdir/dumps/Test_statusline_showcmd_2.dump
@@ -1,6 +1,6 @@
-|a+0&#ffffff0| @73
+>a+0&#ffffff0| @73
 |b| @73
->c| @73
+|c| @73
 |~+0#4040ff13&| @73
-|1+3#0000000&|2|3|4| @70
+| +3#0000000&@74
 | +0&&@74
diff --git a/src/testdir/dumps/Test_statusline_showcmd_3.dump b/src/testdir/dumps/Test_statusline_showcmd_3.dump
index 26ba377..049e0f7 100644
--- a/src/testdir/dumps/Test_statusline_showcmd_3.dump
+++ b/src/testdir/dumps/Test_statusline_showcmd_3.dump
@@ -1,6 +1,6 @@
-|a+0&#ffffff0| @73
-|b| @73
->c| @73
+|a+0&#e0e0e08| +0&#ffffff0@73
+|b+0&#e0e0e08| +0&#ffffff0@73
+|c+0&#e0e0e08> +0&#ffffff0@73
 |~+0#4040ff13&| @73
-|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @32|1|2|3|4| @6|3|,|1| @11|A|l@1
-|:+0&&| @73
+|3+3#0000000&|x|2| @71
+|-+2&&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@56
diff --git a/src/testdir/dumps/Test_statusline_showcmd_4.dump b/src/testdir/dumps/Test_statusline_showcmd_4.dump
new file mode 100644
index 0000000..c443662
--- /dev/null
+++ b/src/testdir/dumps/Test_statusline_showcmd_4.dump
@@ -0,0 +1,6 @@
+|a+0&#ffffff0| @73
+|b| @73
+>c| @73
+|~+0#4040ff13&| @73
+|1+3#0000000&|2|3|4| @70
+| +0&&@74
diff --git a/src/testdir/dumps/Test_statusline_showcmd_5.dump b/src/testdir/dumps/Test_statusline_showcmd_5.dump
new file mode 100644
index 0000000..26ba377
--- /dev/null
+++ b/src/testdir/dumps/Test_statusline_showcmd_5.dump
@@ -0,0 +1,6 @@
+|a+0&#ffffff0| @73
+|b| @73
+>c| @73
+|~+0#4040ff13&| @73
+|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @32|1|2|3|4| @6|3|,|1| @11|A|l@1
+|:+0&&| @73
diff --git a/src/testdir/dumps/Test_tabline_showcmd_1.dump b/src/testdir/dumps/Test_tabline_showcmd_1.dump
index de8f62c..40fea4e 100644
--- a/src/testdir/dumps/Test_tabline_showcmd_1.dump
+++ b/src/testdir/dumps/Test_tabline_showcmd_1.dump
@@ -1,6 +1,6 @@
-| +2&#ffffff0|+| |[|N|o| |N|a|m|e|]| | +1&&@51|3+8#0000001#e0e0e08|x|2| +1#0000000#ffffff0@6
-|a+0&#e0e0e08| +0&#ffffff0@73
-|b+0&#e0e0e08| +0&#ffffff0@73
-|c+0&#e0e0e08> +0&#ffffff0@73
+|g+1&#ffffff0| @73
+|++0#0000e05#a8a8a8255|-@1| @1|2| |l|i|n|e|s|:| |a|-@59
+>c+0#0000000#ffffff0| @73
 |~+0#4040ff13&| @73
-|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@38|3|,|2| @10|A|l@1| 
+|~| @73
+| +0#0000000&@56|3|,|1| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabline_showcmd_2.dump b/src/testdir/dumps/Test_tabline_showcmd_2.dump
index b5a7283..9765de4 100644
--- a/src/testdir/dumps/Test_tabline_showcmd_2.dump
+++ b/src/testdir/dumps/Test_tabline_showcmd_2.dump
@@ -1,6 +1,6 @@
-| +2&#ffffff0|+| |[|N|o| |N|a|m|e|]| | +1&&@51|1+8#0000001#e0e0e08|2|3|4| +1#0000000#ffffff0@5
-|a+0&&| @73
+| +1&#ffffff0@74
+>a+0&&| @73
 |b| @73
->c| @73
+|c| @73
 |~+0#4040ff13&| @73
-| +0#0000000&@56|3|,|1| @10|A|l@1| 
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabline_showcmd_3.dump b/src/testdir/dumps/Test_tabline_showcmd_3.dump
new file mode 100644
index 0000000..3e29cda
--- /dev/null
+++ b/src/testdir/dumps/Test_tabline_showcmd_3.dump
@@ -0,0 +1,6 @@
+|3+1&#ffffff0|x|2| @71
+|a+0&#e0e0e08| +0&#ffffff0@73
+|b+0&#e0e0e08| +0&#ffffff0@73
+|c+0&#e0e0e08> +0&#ffffff0@73
+|~+0#4040ff13&| @73
+|-+2#0000000&@1| |V|I|S|U|A|L| |B|L|O|C|K| |-@1| +0&&@38|3|,|2| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_tabline_showcmd_4.dump b/src/testdir/dumps/Test_tabline_showcmd_4.dump
new file mode 100644
index 0000000..f9aac49
--- /dev/null
+++ b/src/testdir/dumps/Test_tabline_showcmd_4.dump
@@ -0,0 +1,6 @@
+|1+1&#ffffff0|2|3|4| @70
+|a+0&&| @73
+|b| @73
+>c| @73
+|~+0#4040ff13&| @73
+| +0#0000000&@56|3|,|1| @10|A|l@1| 
diff --git a/src/testdir/test_statusline.vim b/src/testdir/test_statusline.vim
index 23613bf..d06e903 100644
--- a/src/testdir/test_statusline.vim
+++ b/src/testdir/test_statusline.vim
@@ -569,22 +569,41 @@
   CheckScreendump
 
   let lines =<< trim END
+    func MyStatusLine()
+      return '%S'
+    endfunc
+
     set laststatus=2
-    set statusline=%S
+    set statusline=%!MyStatusLine()
     set showcmdloc=statusline
     call setline(1, ['a', 'b', 'c'])
+    set foldopen+=jump
+    1,2fold
+    3
   END
   call writefile(lines, 'XTest_statusline', 'D')
 
   let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 6})
-  call feedkeys("\<C-V>Gl", "xt")
+
+  call term_sendkeys(buf, "g")
   call VerifyScreenDump(buf, 'Test_statusline_showcmd_1', {})
 
-  call feedkeys("\<Esc>1234", "xt")
+  " typing "gg" should open the fold
+  call term_sendkeys(buf, "g")
   call VerifyScreenDump(buf, 'Test_statusline_showcmd_2', {})
 
-  call feedkeys("\<Esc>:set statusline=\<CR>:\<CR>1234", "xt")
+  call term_sendkeys(buf, "\<C-V>Gl")
   call VerifyScreenDump(buf, 'Test_statusline_showcmd_3', {})
+
+  call term_sendkeys(buf, "\<Esc>1234")
+  call VerifyScreenDump(buf, 'Test_statusline_showcmd_4', {})
+
+  call term_sendkeys(buf, "\<Esc>:set statusline=\<CR>")
+  call term_sendkeys(buf, ":\<CR>")
+  call term_sendkeys(buf, "1234")
+  call VerifyScreenDump(buf, 'Test_statusline_showcmd_5', {})
+
+  call StopVimInTerminal(buf)
 endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_tabline.vim b/src/testdir/test_tabline.vim
index da73884..09adf2f 100644
--- a/src/testdir/test_tabline.vim
+++ b/src/testdir/test_tabline.vim
@@ -165,19 +165,41 @@
   CheckScreendump
 
   let lines =<< trim END
+    func MyTabLine()
+      return '%S'
+    endfunc
+
     set showtabline=2
+    set tabline=%!MyTabLine()
     set showcmdloc=tabline
     call setline(1, ['a', 'b', 'c'])
+    set foldopen+=jump
+    1,2fold
+    3
   END
   call writefile(lines, 'XTest_tabline', 'D')
 
   let buf = RunVimInTerminal('-S XTest_tabline', {'rows': 6})
 
-  call feedkeys("\<C-V>Gl", "xt")
+  call term_sendkeys(buf, "g")
   call VerifyScreenDump(buf, 'Test_tabline_showcmd_1', {})
 
-  call feedkeys("\<Esc>1234", "xt")
+  " typing "gg" should open the fold
+  call term_sendkeys(buf, "g")
   call VerifyScreenDump(buf, 'Test_tabline_showcmd_2', {})
+
+  call term_sendkeys(buf, "\<C-V>Gl")
+  call VerifyScreenDump(buf, 'Test_tabline_showcmd_3', {})
+
+  call term_sendkeys(buf, "\<Esc>1234")
+  call VerifyScreenDump(buf, 'Test_tabline_showcmd_4', {})
+
+  call term_sendkeys(buf, "\<Esc>:set tabline=\<CR>")
+  call term_sendkeys(buf, ":\<CR>")
+  call term_sendkeys(buf, "1234")
+  call VerifyScreenDump(buf, 'Test_tabline_showcmd_5', {})
+
+  call StopVimInTerminal(buf)
 endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim
index 3e84189..a97ccba 100644
--- a/src/testdir/test_window_cmd.vim
+++ b/src/testdir/test_window_cmd.vim
@@ -1861,6 +1861,8 @@
 
   call term_sendkeys(buf, ":quit\<CR>Gt")
   call VerifyScreenDump(buf, 'Test_splitkeep_callback_4', {})
+
+  call StopVimInTerminal(buf)
 endfunc
 
 function Test_splitkeep_fold()
@@ -1891,6 +1893,8 @@
 
   call term_sendkeys(buf, ":wincmd k\<CR>:quit\<CR>")
   call VerifyScreenDump(buf, 'Test_splitkeep_fold_4', {})
+
+  call StopVimInTerminal(buf)
 endfunction
 
 function Test_splitkeep_status()
@@ -1909,6 +1913,8 @@
 
   call term_sendkeys(buf, ":call win_move_statusline(win, 1)\<CR>")
   call VerifyScreenDump(buf, 'Test_splitkeep_status_1', {})
+
+  call StopVimInTerminal(buf)
 endfunction
 
 function Test_new_help_window_on_error()
diff --git a/src/version.c b/src/version.c
index 65c9e35..7a02894 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1195,
+/**/
     1194,
 /**/
     1193,