test_statusline.vim 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. " Test 'statusline'
  2. "
  3. " Not tested yet:
  4. " %N
  5. source view_util.vim
  6. source check.vim
  7. source term_util.vim
  8. func SetUp()
  9. set laststatus=2
  10. endfunc
  11. func TearDown()
  12. set laststatus&
  13. endfunc
  14. func s:get_statusline()
  15. return ScreenLines(&lines - 1, &columns)[0]
  16. endfunc
  17. func StatuslineWithCaughtError()
  18. let s:func_in_statusline_called = 1
  19. try
  20. call eval('unknown expression')
  21. catch
  22. endtry
  23. return ''
  24. endfunc
  25. func StatuslineWithError()
  26. let s:func_in_statusline_called = 1
  27. call eval('unknown expression')
  28. return ''
  29. endfunc
  30. " Function used to display syntax group.
  31. func SyntaxItem()
  32. call assert_equal(s:expected_curbuf, g:actual_curbuf)
  33. call assert_equal(s:expected_curwin, g:actual_curwin)
  34. return synIDattr(synID(line("."), col("."),1), "name")
  35. endfunc
  36. func Test_caught_error_in_statusline()
  37. let s:func_in_statusline_called = 0
  38. let statusline = '%{StatuslineWithCaughtError()}'
  39. let &statusline = statusline
  40. redrawstatus
  41. call assert_true(s:func_in_statusline_called)
  42. call assert_equal(statusline, &statusline)
  43. set statusline=
  44. endfunc
  45. func Test_statusline_will_be_disabled_with_error()
  46. let s:func_in_statusline_called = 0
  47. let statusline = '%{StatuslineWithError()}'
  48. try
  49. let &statusline = statusline
  50. redrawstatus
  51. catch
  52. endtry
  53. call assert_true(s:func_in_statusline_called)
  54. call assert_equal('', &statusline)
  55. set statusline=
  56. endfunc
  57. func Test_statusline()
  58. CheckFeature quickfix
  59. " %a: Argument list ({current} of {max})
  60. set statusline=%a
  61. call assert_match('^\s*$', s:get_statusline())
  62. arglocal a1 a2
  63. rewind
  64. call assert_match('^ (1 of 2)\s*$', s:get_statusline())
  65. next
  66. call assert_match('^ (2 of 2)\s*$', s:get_statusline())
  67. e Xstatusline
  68. call assert_match('^ ((2) of 2)\s*$', s:get_statusline())
  69. only
  70. set splitbelow
  71. call setline(1, range(1, 10000))
  72. " %b: Value of character under cursor.
  73. " %B: As above, in hexadecimal.
  74. call cursor(9000, 1)
  75. set statusline=%b,%B
  76. call assert_match('^57,39\s*$', s:get_statusline())
  77. " %o: Byte number in file of byte under cursor, first byte is 1.
  78. " %O: As above, in hexadecimal.
  79. set statusline=%o,%O
  80. set fileformat=dos
  81. call assert_match('^52888,CE98\s*$', s:get_statusline())
  82. set fileformat=mac
  83. call assert_match('^43889,AB71\s*$', s:get_statusline())
  84. set fileformat=unix
  85. call assert_match('^43889,AB71\s*$', s:get_statusline())
  86. set fileformat&
  87. " %f: Path to the file in the buffer, as typed or relative to current dir.
  88. set statusline=%f
  89. call assert_match('^Xstatusline\s*$', s:get_statusline())
  90. " %F: Full path to the file in the buffer.
  91. set statusline=%F
  92. call assert_match('/testdir/Xstatusline\s*$', s:get_statusline())
  93. " Test for min and max width with %(. For some reason, if this test is moved
  94. " after the below test for the help buffer flag, then the code to truncate
  95. " the string is not executed.
  96. set statusline=%015(%f%)
  97. call assert_match('^ Xstatusline\s*$', s:get_statusline())
  98. set statusline=%.6(%f%)
  99. call assert_match('^<sline\s*$', s:get_statusline())
  100. set statusline=%14f
  101. call assert_match('^ Xstatusline\s*$', s:get_statusline())
  102. set statusline=%.4L
  103. call assert_match('^10>3\s*$', s:get_statusline())
  104. " %h: Help buffer flag, text is "[help]".
  105. " %H: Help buffer flag, text is ",HLP".
  106. set statusline=%h,%H
  107. call assert_match('^,\s*$', s:get_statusline())
  108. help
  109. call assert_match('^\[Help\],HLP\s*$', s:get_statusline())
  110. helpclose
  111. " %k: Value of "b:keymap_name" or 'keymap'
  112. " when :lmap mappings are being used: <keymap>"
  113. set statusline=%k
  114. if has('keymap')
  115. set keymap=esperanto
  116. call assert_match('^<Eo>\s*$', s:get_statusline())
  117. set keymap&
  118. else
  119. call assert_match('^\s*$', s:get_statusline())
  120. endif
  121. " %l: Line number.
  122. " %L: Number of line in buffer.
  123. " %c: Column number.
  124. set statusline=%l/%L,%c
  125. call assert_match('^9000/10000,1\s*$', s:get_statusline())
  126. " %m: Modified flag, text is "[+]", "[-]" if 'modifiable' is off.
  127. " %M: Modified flag, text is ",+" or ",-".
  128. set statusline=%m%M
  129. call assert_match('^\[+\],+\s*$', s:get_statusline())
  130. set nomodifiable
  131. call assert_match('^\[+-\],+-\s*$', s:get_statusline())
  132. write
  133. call assert_match('^\[-\],-\s*$', s:get_statusline())
  134. set modifiable&
  135. call assert_match('^\s*$', s:get_statusline())
  136. " %n: Buffer number.
  137. set statusline=%n
  138. call assert_match('^'.bufnr('%').'\s*$', s:get_statusline())
  139. " %p: Percentage through file in lines as in CTRL-G.
  140. " %P: Percentage through file of displayed window.
  141. set statusline=%p,%P
  142. 0
  143. call assert_match('^0,Top\s*$', s:get_statusline())
  144. norm G
  145. call assert_match('^100,Bot\s*$', s:get_statusline())
  146. 9000
  147. " Don't check the exact percentage as it depends on the window size
  148. call assert_match('^90,\(Top\|Bot\|\d\+%\)\s*$', s:get_statusline())
  149. " %q: "[Quickfix List]", "[Location List]" or empty.
  150. set statusline=%q
  151. call assert_match('^\s*$', s:get_statusline())
  152. copen
  153. call assert_match('^\[Quickfix List\]\s*$', s:get_statusline())
  154. cclose
  155. lexpr getline(1, 2)
  156. lopen
  157. call assert_match('^\[Location List\]\s*$', s:get_statusline())
  158. lclose
  159. " %r: Readonly flag, text is "[RO]".
  160. " %R: Readonly flag, text is ",RO".
  161. set statusline=%r,%R
  162. call assert_match('^,\s*$', s:get_statusline())
  163. help
  164. call assert_match('^\[RO\],RO\s*$', s:get_statusline())
  165. helpclose
  166. " %t: File name (tail) of file in the buffer.
  167. set statusline=%t
  168. call assert_match('^Xstatusline\s*$', s:get_statusline())
  169. " %v: Virtual column number.
  170. " %V: Virtual column number as -{num}. Not displayed if equal to 'c'.
  171. call cursor(9000, 2)
  172. set statusline=%v,%V
  173. call assert_match('^2,\s*$', s:get_statusline())
  174. set virtualedit=all
  175. norm 10|
  176. call assert_match('^10,-10\s*$', s:get_statusline())
  177. set list
  178. call assert_match('^10,-10\s*$', s:get_statusline())
  179. set virtualedit&
  180. exe "norm A\<Tab>\<Tab>a\<Esc>"
  181. " In list mode a <Tab> is shown as "^I", which is 2-wide.
  182. call assert_match('^9,-9\s*$', s:get_statusline())
  183. set list&
  184. " Now the second <Tab> ends at the 16th screen column.
  185. call assert_match('^17,-17\s*$', s:get_statusline())
  186. undo
  187. " %w: Preview window flag, text is "[Preview]".
  188. " %W: Preview window flag, text is ",PRV".
  189. set statusline=%w%W
  190. call assert_match('^\s*$', s:get_statusline())
  191. pedit
  192. wincmd j
  193. call assert_match('^\[Preview\],PRV\s*$', s:get_statusline())
  194. pclose
  195. pbuffer
  196. wincmd j
  197. call assert_match('^\[Preview\],PRV\s*$', s:get_statusline())
  198. pclose
  199. " %y: Type of file in the buffer, e.g., "[vim]". See 'filetype'.
  200. " %Y: Type of file in the buffer, e.g., ",VIM". See 'filetype'.
  201. set statusline=%y\ %Y
  202. call assert_match('^\s*$', s:get_statusline())
  203. setfiletype vim
  204. call assert_match('^\[vim\] VIM\s*$', s:get_statusline())
  205. " %=: Separation point between left and right aligned items.
  206. set statusline=foo%=bar
  207. call assert_match('^foo\s\+bar\s*$', s:get_statusline())
  208. set statusline=foo%=bar%=baz
  209. call assert_match('^foo\s\+bar\s\+baz\s*$', s:get_statusline())
  210. set statusline=foo%=bar%=baz%=qux
  211. call assert_match('^foo\s\+bar\s\+baz\s\+qux\s*$', s:get_statusline())
  212. " Test min/max width, leading zeroes, left/right justify.
  213. set statusline=%04B
  214. call cursor(9000, 1)
  215. call assert_match('^0039\s*$', s:get_statusline())
  216. set statusline=#%4B#
  217. call assert_match('^# 39#\s*$', s:get_statusline())
  218. set statusline=#%-4B#
  219. call assert_match('^#39 #\s*$', s:get_statusline())
  220. set statusline=%.6f
  221. call assert_match('^<sline\s*$', s:get_statusline())
  222. " %<: Where to truncate.
  223. " First check with when %< should not truncate with many columns
  224. exe 'set statusline=a%<b' . repeat('c', &columns - 3) . 'd'
  225. call assert_match('^abc\+d$', s:get_statusline())
  226. exe 'set statusline=a' . repeat('b', &columns - 2) . '%<c'
  227. call assert_match('^ab\+c$', s:get_statusline())
  228. " Then check when %< should truncate when there with too few columns.
  229. exe 'set statusline=a%<b' . repeat('c', &columns - 2) . 'd'
  230. call assert_match('^a<c\+d$', s:get_statusline())
  231. exe 'set statusline=a' . repeat('b', &columns - 1) . '%<c'
  232. call assert_match('^ab\+>$', s:get_statusline())
  233. "%{: Evaluate expression between '%{' and '}' and substitute result.
  234. syntax on
  235. let s:expected_curbuf = string(bufnr(''))
  236. let s:expected_curwin = string(win_getid())
  237. set statusline=%{SyntaxItem()}
  238. call assert_match('^vimNumber\s*$', s:get_statusline())
  239. s/^/"/
  240. call assert_match('^vimLineComment\s*$', s:get_statusline())
  241. syntax off
  242. "%{%expr%}: evaluates expressions present in result of expr
  243. func! Inner_eval()
  244. return '%n some other text'
  245. endfunc
  246. func! Outer_eval()
  247. return 'some text %{%Inner_eval()%}'
  248. endfunc
  249. set statusline=%{%Outer_eval()%}
  250. call assert_match('^some text ' . bufnr() . ' some other text\s*$', s:get_statusline())
  251. delfunc Inner_eval
  252. delfunc Outer_eval
  253. "%{%expr%}: Doesn't get stuck in recursion
  254. func! Recurse_eval()
  255. return '%{%Recurse_eval()%}'
  256. endfunc
  257. set statusline=%{%Recurse_eval()%}
  258. call assert_match('^%{%Recurse_eval()%}\s*$', s:get_statusline())
  259. delfunc Recurse_eval
  260. "%(: Start of item group.
  261. set statusline=ab%(cd%q%)de
  262. call assert_match('^abde\s*$', s:get_statusline())
  263. copen
  264. call assert_match('^abcd\[Quickfix List]de\s*$', s:get_statusline())
  265. cclose
  266. " %#: Set highlight group. The name must follow and then a # again.
  267. set statusline=ab%#Todo#cd%#Error#ef
  268. call assert_match('^abcdef\s*$', s:get_statusline())
  269. let sa1=screenattr(&lines - 1, 1)
  270. let sa2=screenattr(&lines - 1, 3)
  271. let sa3=screenattr(&lines - 1, 5)
  272. call assert_notequal(sa1, sa2)
  273. call assert_notequal(sa1, sa3)
  274. call assert_notequal(sa2, sa3)
  275. call assert_equal(sa1, screenattr(&lines - 1, 2))
  276. call assert_equal(sa2, screenattr(&lines - 1, 4))
  277. call assert_equal(sa3, screenattr(&lines - 1, 6))
  278. call assert_equal(sa3, screenattr(&lines - 1, 7))
  279. " %*: Set highlight group to User{N}
  280. set statusline=a%1*b%0*c
  281. call assert_match('^abc\s*$', s:get_statusline())
  282. let sa1=screenattr(&lines - 1, 1)
  283. let sa2=screenattr(&lines - 1, 2)
  284. let sa3=screenattr(&lines - 1, 3)
  285. call assert_equal(sa1, sa3)
  286. call assert_notequal(sa1, sa2)
  287. " An empty group that contains highlight changes
  288. let g:a = ''
  289. set statusline=ab%(cd%1*%{g:a}%*%)de
  290. call assert_match('^abde\s*$', s:get_statusline())
  291. let sa1=screenattr(&lines - 1, 1)
  292. let sa2=screenattr(&lines - 1, 4)
  293. call assert_equal(sa1, sa2)
  294. let g:a = 'X'
  295. call assert_match('^abcdXde\s*$', s:get_statusline())
  296. let sa1=screenattr(&lines - 1, 1)
  297. let sa2=screenattr(&lines - 1, 5)
  298. let sa3=screenattr(&lines - 1, 7)
  299. call assert_equal(sa1, sa3)
  300. call assert_notequal(sa1, sa2)
  301. let g:a = ''
  302. set statusline=ab%1*%(cd%*%{g:a}%1*%)de
  303. call assert_match('^abde\s*$', s:get_statusline())
  304. let sa1=screenattr(&lines - 1, 1)
  305. let sa2=screenattr(&lines - 1, 4)
  306. call assert_notequal(sa1, sa2)
  307. let g:a = 'X'
  308. call assert_match('^abcdXde\s*$', s:get_statusline())
  309. let sa1=screenattr(&lines - 1, 1)
  310. let sa2=screenattr(&lines - 1, 3)
  311. let sa3=screenattr(&lines - 1, 5)
  312. let sa4=screenattr(&lines - 1, 7)
  313. call assert_notequal(sa1, sa2)
  314. call assert_equal(sa1, sa3)
  315. call assert_equal(sa2, sa4)
  316. " An empty group that contains highlight changes and doesn't reset them
  317. let g:a = ''
  318. set statusline=ab%(cd%1*%{g:a}%)de
  319. call assert_match('^abcdde\s*$', s:get_statusline())
  320. let sa1=screenattr(&lines - 1, 1)
  321. let sa2=screenattr(&lines - 1, 5)
  322. call assert_notequal(sa1, sa2)
  323. let g:a = 'X'
  324. call assert_match('^abcdXde\s*$', s:get_statusline())
  325. let sa1=screenattr(&lines - 1, 1)
  326. let sa2=screenattr(&lines - 1, 5)
  327. let sa3=screenattr(&lines - 1, 7)
  328. call assert_notequal(sa1, sa2)
  329. call assert_equal(sa2, sa3)
  330. let g:a = ''
  331. set statusline=ab%1*%(cd%*%{g:a}%)de
  332. call assert_match('^abcdde\s*$', s:get_statusline())
  333. let sa1=screenattr(&lines - 1, 1)
  334. let sa2=screenattr(&lines - 1, 3)
  335. let sa3=screenattr(&lines - 1, 5)
  336. call assert_notequal(sa1, sa2)
  337. call assert_equal(sa1, sa3)
  338. let g:a = 'X'
  339. call assert_match('^abcdXde\s*$', s:get_statusline())
  340. let sa1=screenattr(&lines - 1, 1)
  341. let sa2=screenattr(&lines - 1, 3)
  342. let sa3=screenattr(&lines - 1, 5)
  343. let sa4=screenattr(&lines - 1, 7)
  344. call assert_notequal(sa1, sa2)
  345. call assert_equal(sa1, sa3)
  346. call assert_equal(sa1, sa4)
  347. let g:a = ''
  348. set statusline=%#Error#{%(\ %{g:a}\ %)}
  349. call assert_match('^{}\s*$', s:get_statusline())
  350. let g:a = 'X'
  351. call assert_match('^{ X }\s*$', s:get_statusline())
  352. " %%: a percent sign.
  353. set statusline=10%%
  354. call assert_match('^10%\s*$', s:get_statusline())
  355. " %!: evaluated expression is used as the option value
  356. set statusline=%!2*3+1
  357. call assert_match('7\s*$', s:get_statusline())
  358. func GetNested()
  359. call assert_equal(string(win_getid()), g:actual_curwin)
  360. call assert_equal(string(bufnr('')), g:actual_curbuf)
  361. return 'nested'
  362. endfunc
  363. func GetStatusLine()
  364. call assert_equal(win_getid(), g:statusline_winid)
  365. return 'the %{GetNested()} line'
  366. endfunc
  367. set statusline=%!GetStatusLine()
  368. call assert_match('the nested line', s:get_statusline())
  369. call assert_false(exists('g:actual_curwin'))
  370. call assert_false(exists('g:actual_curbuf'))
  371. call assert_false(exists('g:statusline_winid'))
  372. delfunc GetNested
  373. delfunc GetStatusLine
  374. " Test statusline works with 80+ items
  375. function! StatusLabel()
  376. redrawstatus
  377. return '[label]'
  378. endfunc
  379. let statusline = '%{StatusLabel()}'
  380. for i in range(150)
  381. let statusline .= '%#TabLine' . (i % 2 == 0 ? 'Fill' : 'Sel') . '#' . string(i)[0]
  382. endfor
  383. let &statusline = statusline
  384. redrawstatus
  385. set statusline&
  386. delfunc StatusLabel
  387. " Check statusline in current and non-current window
  388. " with the 'fillchars' option.
  389. set fillchars=stl:^,stlnc:=,vert:\|,fold:-,diff:-
  390. vsplit
  391. set statusline=x%=y
  392. call assert_match('^x^\+y^x=\+y$', s:get_statusline())
  393. set fillchars&
  394. close
  395. %bw!
  396. call delete('Xstatusline')
  397. set statusline&
  398. set splitbelow&
  399. endfunc
  400. func Test_statusline_trailing_percent_zero()
  401. " this was causing illegal memory access
  402. set laststatus=2 stl=%!%0
  403. call assert_fails('redraw', 'E15: Invalid expression: "%0"')
  404. set laststatus& stl&
  405. endfunc
  406. func Test_statusline_visual()
  407. func CallWordcount()
  408. call wordcount()
  409. endfunc
  410. new x1
  411. setl statusline=count=%{CallWordcount()}
  412. " buffer must not be empty
  413. call setline(1, 'hello')
  414. " window with more lines than x1
  415. new x2
  416. call setline(1, range(10))
  417. $
  418. " Visual mode in line below liast line in x1 should not give ml_get error
  419. call feedkeys("\<C-V>", "xt")
  420. redraw
  421. delfunc CallWordcount
  422. bwipe! x1
  423. bwipe! x2
  424. endfunc
  425. func Test_statusline_removed_group()
  426. if !CanRunVimInTerminal()
  427. throw 'Skipped: cannot make screendumps'
  428. endif
  429. let lines =<< trim END
  430. scriptencoding utf-8
  431. set laststatus=2
  432. let &statusline = '%#StatColorHi2#%(✓%#StatColorHi2#%) Q≡'
  433. END
  434. call writefile(lines, 'XTest_statusline', 'D')
  435. let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 10, 'cols': 50})
  436. call VerifyScreenDump(buf, 'Test_statusline_1', {})
  437. " clean up
  438. call StopVimInTerminal(buf)
  439. endfunc
  440. func Test_statusline_using_mode()
  441. CheckScreendump
  442. let lines =<< trim END
  443. setlocal statusline=-%{mode()}-
  444. split
  445. setlocal statusline=+%{mode()}+
  446. END
  447. call writefile(lines, 'XTest_statusline', 'D')
  448. let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 7, 'cols': 50})
  449. call VerifyScreenDump(buf, 'Test_statusline_mode_1', {})
  450. call term_sendkeys(buf, ":")
  451. call VerifyScreenDump(buf, 'Test_statusline_mode_2', {})
  452. " clean up
  453. call term_sendkeys(buf, "close\<CR>")
  454. call StopVimInTerminal(buf)
  455. endfunc
  456. func Test_statusline_after_split_vsplit()
  457. only
  458. " Make the status line of each window show the window number.
  459. set ls=2 stl=%{winnr()}
  460. split | redraw
  461. vsplit | redraw
  462. " The status line of the third window should read '3' here.
  463. call assert_equal('3', nr2char(screenchar(&lines - 1, 1)))
  464. only
  465. set ls& stl&
  466. endfunc
  467. " Test using a multibyte character for 'stl' and 'stlnc' items in 'fillchars'
  468. " with a custom 'statusline'
  469. func Test_statusline_mbyte_fillchar()
  470. only
  471. set fillchars=vert:\|,fold:-,stl:━,stlnc:═
  472. set statusline=a%=b
  473. call assert_match('^a\+━\+b$', s:get_statusline())
  474. vnew
  475. call assert_match('^a\+━\+b━a\+═\+b$', s:get_statusline())
  476. wincmd w
  477. call assert_match('^a\+═\+b═a\+━\+b$', s:get_statusline())
  478. set statusline& fillchars&
  479. %bw!
  480. endfunc
  481. " Used to write beyond allocated memory. This assumes MAXPATHL is 4096 bytes.
  482. func Test_statusline_verylong_filename()
  483. let fname = repeat('x', 4090)
  484. " Nvim's swap file creation fails on Windows (E303) due to fname's length
  485. " exe "new " .. fname
  486. exe "noswapfile new " .. fname
  487. set buftype=help
  488. set previewwindow
  489. redraw
  490. bwipe!
  491. endfunc
  492. func Test_statusline_highlight_truncate()
  493. CheckScreendump
  494. let lines =<< trim END
  495. set laststatus=2
  496. hi! link User1 Directory
  497. hi! link User2 ErrorMsg
  498. set statusline=%.5(%1*ABC%2*DEF%1*GHI%)
  499. END
  500. call writefile(lines, 'XTest_statusline', 'D')
  501. let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 6})
  502. call VerifyScreenDump(buf, 'Test_statusline_hl', {})
  503. call StopVimInTerminal(buf)
  504. endfunc
  505. func Test_statusline_showcmd()
  506. CheckScreendump
  507. let lines =<< trim END
  508. func MyStatusLine()
  509. return '%S'
  510. endfunc
  511. set laststatus=2
  512. set statusline=%!MyStatusLine()
  513. set showcmdloc=statusline
  514. call setline(1, ['a', 'b', 'c'])
  515. set foldopen+=jump
  516. 1,2fold
  517. 3
  518. END
  519. call writefile(lines, 'XTest_statusline', 'D')
  520. let buf = RunVimInTerminal('-S XTest_statusline', {'rows': 6})
  521. call term_sendkeys(buf, "g")
  522. call VerifyScreenDump(buf, 'Test_statusline_showcmd_1', {})
  523. " typing "gg" should open the fold
  524. call term_sendkeys(buf, "g")
  525. call VerifyScreenDump(buf, 'Test_statusline_showcmd_2', {})
  526. call term_sendkeys(buf, "\<C-V>Gl")
  527. call VerifyScreenDump(buf, 'Test_statusline_showcmd_3', {})
  528. call term_sendkeys(buf, "\<Esc>1234")
  529. call VerifyScreenDump(buf, 'Test_statusline_showcmd_4', {})
  530. call term_sendkeys(buf, "\<Esc>:set statusline=\<CR>")
  531. call term_sendkeys(buf, ":\<CR>")
  532. call term_sendkeys(buf, "1234")
  533. call VerifyScreenDump(buf, 'Test_statusline_showcmd_5', {})
  534. call StopVimInTerminal(buf)
  535. endfunc
  536. func Test_statusline_highlight_group_cleared()
  537. CheckScreendump
  538. " the laststatus option is there to prevent
  539. " the code-style test from complaining about
  540. " trailing whitespace
  541. let lines =<< trim END
  542. set fillchars=stl:\ ,stlnc:\ laststatus=2
  543. split
  544. hi clear StatusLine
  545. hi clear StatusLineNC
  546. END
  547. call writefile(lines, 'XTest_statusline_stl', 'D')
  548. let buf = RunVimInTerminal('-S XTest_statusline_stl', {})
  549. call VerifyScreenDump(buf, 'Test_statusline_stl_1', {})
  550. call StopVimInTerminal(buf)
  551. endfunc
  552. " vim: shiftwidth=2 sts=2 expandtab