test_messages.vim 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. " Tests for :messages, :echomsg, :echoerr
  2. source check.vim
  3. source shared.vim
  4. source term_util.vim
  5. source view_util.vim
  6. source screendump.vim
  7. func Test_messages()
  8. let oldmore = &more
  9. try
  10. set nomore
  11. let arr = map(range(10), '"hello" . v:val')
  12. for s in arr
  13. echomsg s | redraw
  14. endfor
  15. " get last two messages
  16. redir => result
  17. 2messages | redraw
  18. redir END
  19. let msg_list = split(result, "\n")
  20. call assert_equal(["hello8", "hello9"], msg_list)
  21. " clear messages without last one
  22. 1messages clear
  23. let msg_list = GetMessages()
  24. call assert_equal(['hello9'], msg_list)
  25. " clear all messages
  26. messages clear
  27. let msg_list = GetMessages()
  28. call assert_equal([], msg_list)
  29. finally
  30. let &more = oldmore
  31. endtry
  32. call assert_fails('message 1', 'E474:')
  33. endfunc
  34. " Patch 7.4.1696 defined the "clearmode()" command for clearing the mode
  35. " indicator (e.g., "-- INSERT --") when ":stopinsert" is invoked. Message
  36. " output could then be disturbed when 'cmdheight' was greater than one.
  37. " This test ensures that the bugfix for this issue remains in place.
  38. func Test_stopinsert_does_not_break_message_output()
  39. set cmdheight=2
  40. redraw!
  41. stopinsert | echo 'test echo'
  42. call assert_equal(116, screenchar(&lines - 1, 1))
  43. call assert_equal(32, screenchar(&lines, 1))
  44. redraw!
  45. stopinsert | echomsg 'test echomsg'
  46. call assert_equal(116, screenchar(&lines - 1, 1))
  47. call assert_equal(32, screenchar(&lines, 1))
  48. redraw!
  49. set cmdheight&
  50. endfunc
  51. func Test_message_completion()
  52. call feedkeys(":message \<C-A>\<C-B>\"\<CR>", 'tx')
  53. call assert_equal('"message clear', @:)
  54. endfunc
  55. func Test_echomsg()
  56. call assert_equal("\nhello", execute(':echomsg "hello"'))
  57. call assert_equal("\n", execute(':echomsg ""'))
  58. call assert_equal("\n12345", execute(':echomsg 12345'))
  59. call assert_equal("\n[]", execute(':echomsg []'))
  60. call assert_equal("\n[1, 2, 3]", execute(':echomsg [1, 2, 3]'))
  61. call assert_equal("\n[1, 2, []]", execute(':echomsg [1, 2, v:_null_list]'))
  62. call assert_equal("\n{}", execute(':echomsg {}'))
  63. call assert_equal("\n{'a': 1, 'b': 2}", execute(':echomsg {"a": 1, "b": 2}'))
  64. if has('float')
  65. call assert_equal("\n1.23", execute(':echomsg 1.23'))
  66. endif
  67. call assert_match("function('<lambda>\\d*')", execute(':echomsg {-> 1234}'))
  68. endfunc
  69. func Test_echoerr()
  70. CheckFunction test_ignore_error
  71. call test_ignore_error('IgNoRe')
  72. call assert_equal("\nIgNoRe hello", execute(':echoerr "IgNoRe hello"'))
  73. call assert_equal("\n12345 IgNoRe", execute(':echoerr 12345 "IgNoRe"'))
  74. call assert_equal("\n[1, 2, 'IgNoRe']", execute(':echoerr [1, 2, "IgNoRe"]'))
  75. call assert_equal("\n{'IgNoRe': 2, 'a': 1}", execute(':echoerr {"a": 1, "IgNoRe": 2}'))
  76. if has('float')
  77. call assert_equal("\n1.23 IgNoRe", execute(':echoerr 1.23 "IgNoRe"'))
  78. endif
  79. eval '<lambda>'->test_ignore_error()
  80. call assert_match("function('<lambda>\\d*')", execute(':echoerr {-> 1234}'))
  81. call test_ignore_error('RESET')
  82. endfunc
  83. func Test_mode_message_at_leaving_insert_by_ctrl_c()
  84. if !has('terminal') || has('gui_running')
  85. return
  86. endif
  87. " Set custom statusline built by user-defined function.
  88. let testfile = 'Xtest.vim'
  89. call writefile([
  90. \ 'func StatusLine() abort',
  91. \ ' return ""',
  92. \ 'endfunc',
  93. \ 'set statusline=%!StatusLine()',
  94. \ 'set laststatus=2',
  95. \ ], testfile)
  96. let rows = 10
  97. let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
  98. call TermWait(buf, 100)
  99. call assert_equal('run', job_status(term_getjob(buf)))
  100. call term_sendkeys(buf, "i")
  101. call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))})
  102. call term_sendkeys(buf, "\<C-C>")
  103. call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))})
  104. call term_sendkeys(buf, ":qall!\<CR>")
  105. call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
  106. exe buf . 'bwipe!'
  107. call delete(testfile)
  108. endfunc
  109. func Test_mode_message_at_leaving_insert_with_esc_mapped()
  110. if !has('terminal') || has('gui_running')
  111. return
  112. endif
  113. " Set custom statusline built by user-defined function.
  114. let testfile = 'Xtest.vim'
  115. call writefile([
  116. \ 'set laststatus=2',
  117. \ 'inoremap <Esc> <Esc>00',
  118. \ ], testfile)
  119. let rows = 10
  120. let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
  121. call WaitForAssert({-> assert_match('0,0-1\s*All$', term_getline(buf, rows - 1))})
  122. call assert_equal('run', job_status(term_getjob(buf)))
  123. call term_sendkeys(buf, "i")
  124. call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))})
  125. call term_sendkeys(buf, "\<Esc>")
  126. call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))})
  127. call term_sendkeys(buf, ":qall!\<CR>")
  128. call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
  129. exe buf . 'bwipe!'
  130. call delete(testfile)
  131. endfunc
  132. func Test_echospace()
  133. set noruler noshowcmd laststatus=1
  134. call assert_equal(&columns - 1, v:echospace)
  135. split
  136. call assert_equal(&columns - 1, v:echospace)
  137. set ruler
  138. call assert_equal(&columns - 1, v:echospace)
  139. close
  140. call assert_equal(&columns - 19, v:echospace)
  141. set showcmd noruler
  142. call assert_equal(&columns - 12, v:echospace)
  143. set showcmd ruler
  144. call assert_equal(&columns - 29, v:echospace)
  145. set showcmdloc=statusline
  146. call assert_equal(&columns - 19, v:echospace)
  147. set showcmdloc=tabline
  148. call assert_equal(&columns - 19, v:echospace)
  149. call assert_fails('set showcmdloc=leap', 'E474:')
  150. call assert_equal(&columns - 19, v:echospace)
  151. set showcmdloc=last
  152. call assert_equal(&columns - 29, v:echospace)
  153. call assert_fails('set showcmdloc=jump', 'E474:')
  154. call assert_equal(&columns - 29, v:echospace)
  155. set ruler& showcmd& showcmdloc&
  156. endfunc
  157. func Test_warning_scroll()
  158. CheckRunVimInTerminal
  159. let lines =<< trim END
  160. call test_override('ui_delay', 50)
  161. set noruler
  162. set readonly
  163. undo
  164. END
  165. call writefile(lines, 'XTestWarningScroll', 'D')
  166. let buf = RunVimInTerminal('', #{rows: 8})
  167. " When the warning comes from a script, messages are scrolled so that the
  168. " stacktrace is visible.
  169. call term_sendkeys(buf, ":source XTestWarningScroll\n")
  170. " only match the final colon in the line that shows the source
  171. call WaitForAssert({-> assert_match(':$', term_getline(buf, 5))})
  172. call WaitForAssert({-> assert_equal('line 4:W10: Warning: Changing a readonly file', term_getline(buf, 6))})
  173. call WaitForAssert({-> assert_equal('Already at oldest change', term_getline(buf, 7))})
  174. call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 8))})
  175. call term_sendkeys(buf, "\n")
  176. " When the warning does not come from a script, messages are not scrolled.
  177. call term_sendkeys(buf, ":enew\n")
  178. call term_sendkeys(buf, ":set readonly\n")
  179. call term_sendkeys(buf, 'u')
  180. call WaitForAssert({-> assert_equal('W10: Warning: Changing a readonly file', term_getline(buf, 8))})
  181. call WaitForAssert({-> assert_equal('Already at oldest change', term_getline(buf, 8))})
  182. " clean up
  183. call StopVimInTerminal(buf)
  184. endfunc
  185. " Test more-prompt (see :help more-prompt).
  186. func Test_message_more()
  187. CheckRunVimInTerminal
  188. let buf = RunVimInTerminal('', {'rows': 6})
  189. call term_sendkeys(buf, ":call setline(1, range(1, 100))\n")
  190. call term_sendkeys(buf, ":%pfoo\<C-H>\<C-H>\<C-H>#")
  191. call WaitForAssert({-> assert_equal(':%p#', term_getline(buf, 6))})
  192. call term_sendkeys(buf, "\n")
  193. call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))})
  194. call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
  195. call term_sendkeys(buf, '?')
  196. call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))})
  197. call WaitForAssert({-> assert_equal('-- More -- SPACE/d/j: screen/page/line down, b/u/k: up, q: quit ', term_getline(buf, 6))})
  198. " Down a line with j, <CR>, <NL> or <Down>.
  199. call term_sendkeys(buf, "j")
  200. call WaitForAssert({-> assert_equal(' 6 6', term_getline(buf, 5))})
  201. call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
  202. call term_sendkeys(buf, "\<NL>")
  203. call WaitForAssert({-> assert_equal(' 7 7', term_getline(buf, 5))})
  204. call term_sendkeys(buf, "\<CR>")
  205. call WaitForAssert({-> assert_equal(' 8 8', term_getline(buf, 5))})
  206. call term_sendkeys(buf, "\<Down>")
  207. call WaitForAssert({-> assert_equal(' 9 9', term_getline(buf, 5))})
  208. " Down a screen with <Space>, f, or <PageDown>.
  209. call term_sendkeys(buf, 'f')
  210. call WaitForAssert({-> assert_equal(' 14 14', term_getline(buf, 5))})
  211. call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
  212. call term_sendkeys(buf, ' ')
  213. call WaitForAssert({-> assert_equal(' 19 19', term_getline(buf, 5))})
  214. call term_sendkeys(buf, "\<PageDown>")
  215. call WaitForAssert({-> assert_equal(' 24 24', term_getline(buf, 5))})
  216. " Down a page (half a screen) with d.
  217. call term_sendkeys(buf, 'd')
  218. call WaitForAssert({-> assert_equal(' 27 27', term_getline(buf, 5))})
  219. " Down all the way with 'G'.
  220. call term_sendkeys(buf, 'G')
  221. call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))})
  222. call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})
  223. " Up a line k, <BS> or <Up>.
  224. call term_sendkeys(buf, 'k')
  225. call WaitForAssert({-> assert_equal(' 99 99', term_getline(buf, 5))})
  226. call term_sendkeys(buf, "\<BS>")
  227. call WaitForAssert({-> assert_equal(' 98 98', term_getline(buf, 5))})
  228. call term_sendkeys(buf, "\<Up>")
  229. call WaitForAssert({-> assert_equal(' 97 97', term_getline(buf, 5))})
  230. " Up a screen with b or <PageUp>.
  231. call term_sendkeys(buf, 'b')
  232. call WaitForAssert({-> assert_equal(' 92 92', term_getline(buf, 5))})
  233. call term_sendkeys(buf, "\<PageUp>")
  234. call WaitForAssert({-> assert_equal(' 87 87', term_getline(buf, 5))})
  235. " Up a page (half a screen) with u.
  236. call term_sendkeys(buf, 'u')
  237. call WaitForAssert({-> assert_equal(' 84 84', term_getline(buf, 5))})
  238. " Up all the way with 'g'.
  239. call term_sendkeys(buf, 'g')
  240. call WaitForAssert({-> assert_equal(' 4 4', term_getline(buf, 5))})
  241. call WaitForAssert({-> assert_equal(':%p#', term_getline(buf, 1))})
  242. call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
  243. " All the way down. Pressing f should do nothing but pressing
  244. " space should end the more prompt.
  245. call term_sendkeys(buf, 'G')
  246. call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))})
  247. call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})
  248. call term_sendkeys(buf, 'f')
  249. call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))})
  250. call term_sendkeys(buf, ' ')
  251. call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))})
  252. " Pressing g< shows the previous command output.
  253. call term_sendkeys(buf, 'g<')
  254. call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 5))})
  255. call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})
  256. " A command line that doesn't print text is appended to scrollback,
  257. " even if it invokes a nested command line.
  258. call term_sendkeys(buf, ":\<C-R>=':'\<CR>:\<CR>g<")
  259. call WaitForAssert({-> assert_equal('100 100', term_getline(buf, 4))})
  260. call WaitForAssert({-> assert_equal(':::', term_getline(buf, 5))})
  261. call WaitForAssert({-> assert_equal('Press ENTER or type command to continue', term_getline(buf, 6))})
  262. call term_sendkeys(buf, ":%p#\n")
  263. call WaitForAssert({-> assert_equal(' 5 5', term_getline(buf, 5))})
  264. call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
  265. " Stop command output with q, <Esc> or CTRL-C.
  266. call term_sendkeys(buf, 'q')
  267. call WaitForAssert({-> assert_equal('100', term_getline(buf, 5))})
  268. " Execute a : command from the more prompt
  269. call term_sendkeys(buf, ":%p#\n")
  270. call term_wait(buf)
  271. call WaitForAssert({-> assert_equal('-- More --', term_getline(buf, 6))})
  272. call term_sendkeys(buf, ":")
  273. call term_wait(buf)
  274. call WaitForAssert({-> assert_equal(':', term_getline(buf, 6))})
  275. call term_sendkeys(buf, "echo 'Hello'\n")
  276. call term_wait(buf)
  277. call WaitForAssert({-> assert_equal('Hello ', term_getline(buf, 5))})
  278. call StopVimInTerminal(buf)
  279. endfunc
  280. " Test more-prompt scrollback
  281. func Test_message_more_scrollback()
  282. CheckRunVimInTerminal
  283. let lines =<< trim END
  284. set t_ut=
  285. hi Normal ctermfg=15 ctermbg=0
  286. for i in range(100)
  287. echo i
  288. endfor
  289. END
  290. call writefile(lines, 'XmoreScrollback', 'D')
  291. let buf = RunVimInTerminal('-S XmoreScrollback', {'rows': 10})
  292. call VerifyScreenDump(buf, 'Test_more_scrollback_1', {})
  293. call term_sendkeys(buf, 'f')
  294. call TermWait(buf)
  295. call term_sendkeys(buf, 'b')
  296. call VerifyScreenDump(buf, 'Test_more_scrollback_2', {})
  297. call term_sendkeys(buf, 'q')
  298. call TermWait(buf)
  299. call StopVimInTerminal(buf)
  300. endfunc
  301. func Test_message_not_cleared_after_mode()
  302. CheckRunVimInTerminal
  303. let lines =<< trim END
  304. nmap <silent> gx :call DebugSilent('normal')<CR>
  305. vmap <silent> gx :call DebugSilent('visual')<CR>
  306. function DebugSilent(arg)
  307. echomsg "from DebugSilent" a:arg
  308. endfunction
  309. set showmode
  310. set cmdheight=1
  311. call test_settime(1)
  312. call setline(1, ['one', 'NoSuchFile', 'three'])
  313. END
  314. call writefile(lines, 'XmessageMode', 'D')
  315. let buf = RunVimInTerminal('-S XmessageMode', {'rows': 10})
  316. call term_sendkeys(buf, 'gx')
  317. call TermWait(buf)
  318. call VerifyScreenDump(buf, 'Test_message_not_cleared_after_mode_1', {})
  319. " removing the mode message used to also clear the intended message
  320. call term_sendkeys(buf, 'vEgx')
  321. call TermWait(buf)
  322. call VerifyScreenDump(buf, 'Test_message_not_cleared_after_mode_2', {})
  323. " removing the mode message used to also clear the error message
  324. call term_sendkeys(buf, ":set cmdheight=2\<CR>")
  325. call term_sendkeys(buf, '2GvEgf')
  326. call TermWait(buf)
  327. call VerifyScreenDump(buf, 'Test_message_not_cleared_after_mode_3', {})
  328. call StopVimInTerminal(buf)
  329. endfunc
  330. " Test verbose message before echo command
  331. func Test_echo_verbose_system()
  332. CheckRunVimInTerminal
  333. CheckUnix " needs the "seq" command
  334. CheckNotMac " doesn't use /tmp
  335. let buf = RunVimInTerminal('', {'rows': 10})
  336. call term_sendkeys(buf, ":4 verbose echo system('seq 20')\<CR>")
  337. " Note that the screendump is filtered to remove the name of the temp file
  338. call VerifyScreenDump(buf, 'Test_verbose_system_1', {})
  339. " display a page and go back, results in exactly the same view
  340. call term_sendkeys(buf, ' ')
  341. call TermWait(buf, 50)
  342. call term_sendkeys(buf, 'b')
  343. call VerifyScreenDump(buf, 'Test_verbose_system_1', {})
  344. " do the same with 'cmdheight' set to 2
  345. call term_sendkeys(buf, 'q')
  346. call TermWait(buf)
  347. call term_sendkeys(buf, ":set ch=2\<CR>")
  348. call TermWait(buf)
  349. call term_sendkeys(buf, ":4 verbose echo system('seq 20')\<CR>")
  350. call VerifyScreenDump(buf, 'Test_verbose_system_2', {})
  351. call term_sendkeys(buf, ' ')
  352. call TermWait(buf, 50)
  353. call term_sendkeys(buf, 'b')
  354. call VerifyScreenDump(buf, 'Test_verbose_system_2', {})
  355. call term_sendkeys(buf, 'q')
  356. call TermWait(buf)
  357. call StopVimInTerminal(buf)
  358. endfunc
  359. func Test_ask_yesno()
  360. CheckRunVimInTerminal
  361. let buf = RunVimInTerminal('', {'rows': 6})
  362. call term_sendkeys(buf, ":call setline(1, range(1, 2))\n")
  363. call term_sendkeys(buf, ":2,1s/^/n/\n")
  364. call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))})
  365. call term_sendkeys(buf, "n")
  366. call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?n *1,1 *All$', term_getline(buf, 6))})
  367. call WaitForAssert({-> assert_equal('1', term_getline(buf, 1))})
  368. call term_sendkeys(buf, ":2,1s/^/Esc/\n")
  369. call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))})
  370. call term_sendkeys(buf, "\<Esc>")
  371. call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?n *1,1 *All$', term_getline(buf, 6))})
  372. call WaitForAssert({-> assert_equal('1', term_getline(buf, 1))})
  373. call term_sendkeys(buf, ":2,1s/^/y/\n")
  374. call WaitForAssert({-> assert_equal('Backwards range given, OK to swap (y/n)?', term_getline(buf, 6))})
  375. call term_sendkeys(buf, "y")
  376. call WaitForAssert({-> assert_match('^Backwards range given, OK to swap (y/n)?y *2,1 *All$', term_getline(buf, 6))})
  377. call WaitForAssert({-> assert_equal('y1', term_getline(buf, 1))})
  378. call WaitForAssert({-> assert_equal('y2', term_getline(buf, 2))})
  379. call StopVimInTerminal(buf)
  380. endfunc
  381. func Test_null()
  382. echom v:_null_list
  383. echom v:_null_dict
  384. echom v:_null_blob
  385. echom v:_null_string
  386. " Nvim doesn't have NULL functions
  387. " echom test_null_function()
  388. " Nvim doesn't have NULL partials
  389. " echom test_null_partial()
  390. if has('job')
  391. echom test_null_job()
  392. echom test_null_channel()
  393. endif
  394. endfunc
  395. func Test_mapping_at_hit_return_prompt()
  396. nnoremap <C-B> :echo "hit ctrl-b"<CR>
  397. call feedkeys(":ls\<CR>", "xt")
  398. call feedkeys("\<*C-B>", "xt")
  399. call assert_match('hit ctrl-b', Screenline(&lines - 1))
  400. nunmap <C-B>
  401. endfunc
  402. func Test_quit_long_message()
  403. CheckScreendump
  404. let content =<< trim END
  405. echom range(9999)->join("\x01")
  406. END
  407. call writefile(content, 'Xtest_quit_message', 'D')
  408. let buf = RunVimInTerminal('-S Xtest_quit_message', #{rows: 10, wait_for_ruler: 0})
  409. call WaitForAssert({-> assert_match('^-- More --', term_getline(buf, 10))})
  410. call term_sendkeys(buf, "q")
  411. call VerifyScreenDump(buf, 'Test_quit_long_message', {})
  412. " clean up
  413. call StopVimInTerminal(buf)
  414. endfunc
  415. " this was missing a terminating NUL
  416. func Test_echo_string_partial()
  417. function CountSpaces()
  418. endfunction
  419. call assert_equal("function('CountSpaces', [{'ccccccccccc': ['ab', 'cd'], 'aaaaaaaaaaa': v:false, 'bbbbbbbbbbbb': ''}])", string(function('CountSpaces', [#{aaaaaaaaaaa: v:false, bbbbbbbbbbbb: '', ccccccccccc: ['ab', 'cd']}])))
  420. endfunc
  421. " Test that fileinfo is shown properly when 'cmdheight' has just decreased
  422. " due to switching tabpage and 'shortmess' doesn't contain 'o' or 'O'.
  423. func Test_fileinfo_tabpage_cmdheight()
  424. CheckRunVimInTerminal
  425. let content =<< trim END
  426. set shortmess-=o
  427. set shortmess-=O
  428. set shortmess-=F
  429. tabnew
  430. set cmdheight=2
  431. tabprev
  432. edit Xfileinfo.txt
  433. END
  434. call writefile(content, 'Xtest_fileinfo_tabpage_cmdheight', 'D')
  435. let buf = RunVimInTerminal('-S Xtest_fileinfo_tabpage_cmdheight', #{rows: 6})
  436. call WaitForAssert({-> assert_match('^"Xfileinfo.txt" \[New\]', term_getline(buf, 6))})
  437. " clean up
  438. call StopVimInTerminal(buf)
  439. endfunc
  440. " Message output was previously overwritten by the fileinfo display, shown
  441. " when switching buffers. If a buffer is switched to, then a message if
  442. " echoed, we should show the message, rather than overwriting it with
  443. " fileinfo.
  444. func Test_fileinfo_after_echo()
  445. CheckScreendump
  446. let content =<< trim END
  447. file a.txt
  448. hide edit b.txt
  449. call setline(1, "hi")
  450. setlocal modified
  451. hide buffer a.txt
  452. autocmd CursorHold * buf b.txt | w | echo "'b' written"
  453. END
  454. call writefile(content, 'Xtest_fileinfo_after_echo')
  455. let buf = RunVimInTerminal('-S Xtest_fileinfo_after_echo', #{rows: 6})
  456. call term_sendkeys(buf, ":set updatetime=50\<CR>")
  457. call term_sendkeys(buf, "0$")
  458. call VerifyScreenDump(buf, 'Test_fileinfo_after_echo', {})
  459. call term_sendkeys(buf, ":q\<CR>")
  460. " clean up
  461. call StopVimInTerminal(buf)
  462. call delete('Xtest_fileinfo_after_echo')
  463. call delete('b.txt')
  464. endfunc
  465. func Test_cmdheight_zero()
  466. enew
  467. set cmdheight=0
  468. set showcmd
  469. redraw!
  470. echo 'test echo'
  471. call assert_equal(116, screenchar(&lines, 1))
  472. redraw!
  473. echomsg 'test echomsg'
  474. call assert_equal(116, screenchar(&lines, 1))
  475. redraw!
  476. call feedkeys(":ls\<CR>", "xt")
  477. call assert_equal(':ls', Screenline(&lines - 1))
  478. redraw!
  479. let char = getchar(0)
  480. call assert_match(char, 0)
  481. " Check change/restore cmdheight when macro
  482. call feedkeys("qa", "xt")
  483. call assert_equal(0, &cmdheight)
  484. call feedkeys("q", "xt")
  485. call assert_equal(0, &cmdheight)
  486. call setline(1, 'somestring')
  487. call feedkeys("y", "n")
  488. %s/somestring/otherstring/gc
  489. call assert_equal('otherstring', getline(1))
  490. call feedkeys("g\<C-g>", "xt")
  491. call assert_match(
  492. \ 'Col 1 of 11; Line 1 of 1; Word 1 of 1',
  493. \ Screenline(&lines))
  494. " Check split behavior
  495. for i in range(1, 10)
  496. split
  497. endfor
  498. only
  499. call assert_equal(0, &cmdheight)
  500. " Check that pressing ":" should not scroll a window
  501. " Check for what patch 9.0.0115 fixes
  502. botright 10new
  503. call setline(1, range(12))
  504. 7
  505. call feedkeys(":\"\<C-R>=line('w0')\<CR>\<CR>", "xt")
  506. call assert_equal('"1', @:)
  507. bwipe!
  508. bwipe!
  509. set cmdheight&
  510. set showcmd&
  511. tabnew
  512. tabonly
  513. endfunc
  514. " vim: shiftwidth=2 sts=2 expandtab