messages_spec.lua 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local clear, feed = helpers.clear, helpers.feed
  4. local eval = helpers.eval
  5. local eq = helpers.eq
  6. local command = helpers.command
  7. local set_method_error = helpers.set_method_error
  8. local meths = helpers.meths
  9. local async_meths = helpers.async_meths
  10. local test_build_dir = helpers.test_build_dir
  11. local nvim_prog = helpers.nvim_prog
  12. local iswin = helpers.iswin
  13. local exc_exec = helpers.exc_exec
  14. local exec_lua = helpers.exec_lua
  15. describe('ui/ext_messages', function()
  16. local screen
  17. before_each(function()
  18. clear()
  19. screen = Screen.new(25, 5)
  20. screen:attach({rgb=true, ext_messages=true, ext_popupmenu=true})
  21. screen:set_default_attr_ids({
  22. [1] = {bold = true, foreground = Screen.colors.Blue1},
  23. [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  24. [3] = {bold = true},
  25. [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
  26. [5] = {foreground = Screen.colors.Blue1},
  27. [6] = {bold = true, reverse = true},
  28. [7] = {background = Screen.colors.Yellow},
  29. [8] = {foreground = Screen.colors.Red},
  30. [9] = {special = Screen.colors.Red, undercurl = true},
  31. })
  32. end)
  33. after_each(function()
  34. os.remove('Xtest')
  35. end)
  36. it('msg_clear follows msg_show kind of confirm', function()
  37. feed('iline 1<esc>')
  38. feed(':call confirm("test")<cr>')
  39. screen:expect{grid=[[
  40. line ^1 |
  41. {1:~ }|
  42. {1:~ }|
  43. {1:~ }|
  44. {1:~ }|
  45. ]], messages={ {
  46. content = {{"\ntest\n[O]k: ", 4}},
  47. kind = 'confirm',
  48. }}}
  49. feed('<cr>')
  50. screen:expect{grid=[[
  51. line ^1 |
  52. {1:~ }|
  53. {1:~ }|
  54. {1:~ }|
  55. {1:~ }|
  56. ]]}
  57. end)
  58. it('msg_show kind=confirm,confirm_sub,emsg,wmsg,quickfix', function()
  59. feed('iline 1\nline 2<esc>')
  60. -- kind=confirm
  61. feed(':echo confirm("test")<cr>')
  62. screen:expect{grid=[[
  63. line 1 |
  64. line ^2 |
  65. {1:~ }|
  66. {1:~ }|
  67. {1:~ }|
  68. ]], messages={ {
  69. content = {{"\ntest\n[O]k: ", 4}},
  70. kind = 'confirm',
  71. }}}
  72. feed('<cr><cr>')
  73. screen:expect{grid=[[
  74. line 1 |
  75. line ^2 |
  76. {1:~ }|
  77. {1:~ }|
  78. {1:~ }|
  79. ]], messages={ {
  80. content = { { "\ntest\n[O]k: ", 4 } },
  81. kind = "confirm"
  82. }, {
  83. content = { { "1" } },
  84. kind = "echo"
  85. }, {
  86. content = { { "Press ENTER or type command to continue", 4 } },
  87. kind = "return_prompt"
  88. } }}
  89. feed('<cr><cr>')
  90. -- kind=confirm_sub
  91. feed(':%s/i/X/gc<cr>')
  92. screen:expect{grid=[[
  93. l{7:i}ne 1 |
  94. l{8:i}ne ^2 |
  95. {1:~ }|
  96. {1:~ }|
  97. {1:~ }|
  98. ]], attr_ids={
  99. [1] = {bold = true, foreground = Screen.colors.Blue1},
  100. [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  101. [3] = {bold = true},
  102. [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
  103. [5] = {foreground = Screen.colors.Blue1},
  104. [6] = {bold = true, reverse = true},
  105. [7] = {reverse = true},
  106. [8] = {background = Screen.colors.Yellow},
  107. }, messages={ {
  108. content = { { "replace with X (y/n/a/q/l/^E/^Y)?", 4 } },
  109. kind = "confirm_sub"
  110. } }}
  111. feed('nq')
  112. -- kind=wmsg (editing readonly file)
  113. command('write Xtest')
  114. command('set readonly nohls')
  115. feed('G$x')
  116. screen:expect{grid=[[
  117. line 1 |
  118. {MATCH:.*}|
  119. {1:~ }|
  120. {1:~ }|
  121. {1:~ }|
  122. ]], attr_ids={
  123. [1] = {bold = true, foreground = Screen.colors.Blue1},
  124. [7] = {foreground = Screen.colors.Red},
  125. }, messages={ {
  126. content = { { "W10: Warning: Changing a readonly file", 7 } },
  127. kind = "wmsg"
  128. }
  129. }}
  130. -- kind=wmsg ('wrapscan' after search reaches EOF)
  131. feed('uG$/i<cr>')
  132. screen:expect{grid=[[
  133. l^ine 1 |
  134. line 2 |
  135. {1:~ }|
  136. {1:~ }|
  137. {1:~ }|
  138. ]], attr_ids={
  139. [1] = {bold = true, foreground = Screen.colors.Blue1},
  140. [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  141. [3] = {bold = true},
  142. [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
  143. [5] = {foreground = Screen.colors.Blue1},
  144. [6] = {bold = true, reverse = true},
  145. [7] = {foreground = Screen.colors.Red},
  146. }, messages={ {
  147. content = { { "search hit BOTTOM, continuing at TOP", 7 } },
  148. kind = "wmsg"
  149. } }}
  150. -- kind=emsg after :throw
  151. feed(':throw "foo"<cr>')
  152. screen:expect{grid=[[
  153. l^ine 1 |
  154. line 2 |
  155. {1:~ }|
  156. {1:~ }|
  157. {1:~ }|
  158. ]], messages={ {
  159. content = { { "Error detected while processing :", 2 } },
  160. kind = "emsg"
  161. }, {
  162. content = { { "E605: Exception not caught: foo", 2 } },
  163. kind = ""
  164. }, {
  165. content = { { "Press ENTER or type command to continue", 4 } },
  166. kind = "return_prompt"
  167. } }
  168. }
  169. -- kind=quickfix after :cnext
  170. feed('<c-c>')
  171. command("caddexpr [expand('%').':1:line1',expand('%').':2:line2']")
  172. feed(':cnext<cr>')
  173. screen:expect{grid=[[
  174. line 1 |
  175. ^line 2 |
  176. {1:~ }|
  177. {1:~ }|
  178. {1:~ }|
  179. ]], messages={ {
  180. content = { { "(2 of 2): line2" } },
  181. kind = "quickfix"
  182. } }}
  183. end)
  184. it(':echoerr', function()
  185. feed(':echoerr "raa"<cr>')
  186. screen:expect{grid=[[
  187. ^ |
  188. {1:~ }|
  189. {1:~ }|
  190. {1:~ }|
  191. {1:~ }|
  192. ]], messages={{
  193. content = {{"raa", 2}},
  194. kind = "echoerr",
  195. }}}
  196. -- cmdline in a later input cycle clears error message
  197. feed(':')
  198. screen:expect{grid=[[
  199. ^ |
  200. {1:~ }|
  201. {1:~ }|
  202. {1:~ }|
  203. {1:~ }|
  204. ]], cmdline={{
  205. firstc = ":",
  206. content = {{ "" }},
  207. pos = 0,
  208. }}}
  209. feed('echoerr "bork" | echoerr "fail"<cr>')
  210. screen:expect{grid=[[
  211. ^ |
  212. {1:~ }|
  213. {1:~ }|
  214. {1:~ }|
  215. {1:~ }|
  216. ]], messages={{
  217. content = {{ "bork", 2 }},
  218. kind = "echoerr"
  219. }, {
  220. content = {{ "fail", 2 }},
  221. kind = "echoerr"
  222. }, {
  223. content = {{ "Press ENTER or type command to continue", 4 }},
  224. kind = "return_prompt"
  225. }}}
  226. feed(':echoerr "extrafail"<cr>')
  227. screen:expect{grid=[[
  228. ^ |
  229. {1:~ }|
  230. {1:~ }|
  231. {1:~ }|
  232. {1:~ }|
  233. ]], messages={{
  234. content = { { "bork", 2 } },
  235. kind = "echoerr"
  236. }, {
  237. content = { { "fail", 2 } },
  238. kind = "echoerr"
  239. }, {
  240. content = { { "extrafail", 2 } },
  241. kind = "echoerr"
  242. }, {
  243. content = { { "Press ENTER or type command to continue", 4 } },
  244. kind = "return_prompt"
  245. }}}
  246. feed('<cr>')
  247. screen:expect{grid=[[
  248. ^ |
  249. {1:~ }|
  250. {1:~ }|
  251. {1:~ }|
  252. {1:~ }|
  253. ]]}
  254. -- cmdline without interleaving wait/display keeps the error message
  255. feed(':echoerr "problem" | let x = input("foo> ")<cr>')
  256. screen:expect{grid=[[
  257. ^ |
  258. {1:~ }|
  259. {1:~ }|
  260. {1:~ }|
  261. {1:~ }|
  262. ]], messages={{
  263. content = {{ "problem", 2 }},
  264. kind = "echoerr"
  265. }}, cmdline={{
  266. prompt = "foo> ",
  267. content = {{ "" }},
  268. pos = 0,
  269. }}}
  270. feed('solution<cr>')
  271. screen:expect{grid=[[
  272. ^ |
  273. {1:~ }|
  274. {1:~ }|
  275. {1:~ }|
  276. {1:~ }|
  277. ]]}
  278. eq('solution', eval('x'))
  279. feed(":messages<cr>")
  280. screen:expect{grid=[[
  281. ^ |
  282. {1:~ }|
  283. {1:~ }|
  284. {1:~ }|
  285. {1:~ }|
  286. ]], messages={
  287. {kind="echoerr", content={{"raa", 2}}},
  288. {kind="echoerr", content={{"bork", 2}}},
  289. {kind="echoerr", content={{"fail", 2}}},
  290. {kind="echoerr", content={{"extrafail", 2}}},
  291. {kind="echoerr", content={{"problem", 2}}}
  292. }}
  293. end)
  294. it('shortmess-=S', function()
  295. command('set shortmess-=S')
  296. feed('iline 1\nline 2<esc>')
  297. feed('/line<cr>')
  298. screen:expect{grid=[[
  299. {7:^line} 1 |
  300. {7:line} 2 |
  301. {1:~ }|
  302. {1:~ }|
  303. {1:~ }|
  304. ]], messages={
  305. {content = {{"/line W [1/2]"}}, kind = "search_count"}
  306. }}
  307. feed('n')
  308. screen:expect{grid=[[
  309. {7:line} 1 |
  310. {7:^line} 2 |
  311. {1:~ }|
  312. {1:~ }|
  313. {1:~ }|
  314. ]], messages={
  315. {content = {{"/line [2/2]"}}, kind = "search_count"}
  316. }}
  317. end)
  318. it(':hi Group output', function()
  319. feed(':hi ErrorMsg<cr>')
  320. screen:expect{grid=[[
  321. ^ |
  322. {1:~ }|
  323. {1:~ }|
  324. {1:~ }|
  325. {1:~ }|
  326. ]], messages={
  327. {content = {{"\nErrorMsg " }, {"xxx", 2}, {" "},
  328. {"ctermfg=", 5 }, { "15 " }, { "ctermbg=", 5 }, { "1 " },
  329. {"guifg=", 5 }, { "White " }, { "guibg=", 5 }, { "Red" }},
  330. kind = ""}
  331. }}
  332. end)
  333. it("doesn't crash with column adjustment #10069", function()
  334. feed(':let [x,y] = [1,2]<cr>')
  335. feed(':let x y<cr>')
  336. screen:expect{grid=[[
  337. ^ |
  338. {1:~ }|
  339. {1:~ }|
  340. {1:~ }|
  341. {1:~ }|
  342. ]], messages={
  343. {content = {{ "x #1" }}, kind = ""},
  344. {content = {{ "y #2" }}, kind = ""},
  345. {content = {{ "Press ENTER or type command to continue", 4 }}, kind = "return_prompt"}
  346. }}
  347. end)
  348. it('&showmode', function()
  349. command('imap <f2> <cmd>echomsg "stuff"<cr>')
  350. feed('i')
  351. screen:expect{grid=[[
  352. ^ |
  353. {1:~ }|
  354. {1:~ }|
  355. {1:~ }|
  356. {1:~ }|
  357. ]], showmode={{"-- INSERT --", 3}}}
  358. feed('alphpabet<cr>alphanum<cr>')
  359. screen:expect{grid=[[
  360. alphpabet |
  361. alphanum |
  362. ^ |
  363. {1:~ }|
  364. {1:~ }|
  365. ]], showmode={ { "-- INSERT --", 3 } }}
  366. feed('<c-x>')
  367. screen:expect{grid=[[
  368. alphpabet |
  369. alphanum |
  370. ^ |
  371. {1:~ }|
  372. {1:~ }|
  373. ]], showmode={ { "-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)", 3 } }}
  374. feed('<c-p>')
  375. screen:expect{grid=[[
  376. alphpabet |
  377. alphanum |
  378. alphanum^ |
  379. {1:~ }|
  380. {1:~ }|
  381. ]], popupmenu={
  382. anchor = { 1, 2, 0 },
  383. items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } },
  384. pos = 1
  385. }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 1 of 2", 4 } }}
  386. -- echomsg and showmode don't overwrite each other, this is the same
  387. -- as the TUI behavior with cmdheight=2 or larger.
  388. feed('<f2>')
  389. screen:expect{grid=[[
  390. alphpabet |
  391. alphanum |
  392. alphanum^ |
  393. {1:~ }|
  394. {1:~ }|
  395. ]], popupmenu={
  396. anchor = { 1, 2, 0 },
  397. items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } },
  398. pos = 1
  399. }, messages={ {
  400. content = { { "stuff" } },
  401. kind = "echomsg"
  402. } }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 1 of 2", 4 } }}
  403. feed('<c-p>')
  404. screen:expect{grid=[[
  405. alphpabet |
  406. alphanum |
  407. alphpabet^ |
  408. {1:~ }|
  409. {1:~ }|
  410. ]], popupmenu={
  411. anchor = { 1, 2, 0 },
  412. items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } },
  413. pos = 0
  414. }, messages={ {
  415. content = { { "stuff" } },
  416. kind = "echomsg"
  417. } }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 2 of 2", 4 } }}
  418. feed("<esc>:messages<cr>")
  419. screen:expect{grid=[[
  420. alphpabet |
  421. alphanum |
  422. alphpabe^t |
  423. {1:~ }|
  424. {1:~ }|
  425. ]], messages={
  426. {kind="echomsg", content={{"stuff"}}},
  427. }, showmode={
  428. { "-- INSERT --", 3 }
  429. }}
  430. end)
  431. it('&showmode with macro-recording message', function()
  432. feed('qq')
  433. screen:expect{grid=[[
  434. ^ |
  435. {1:~ }|
  436. {1:~ }|
  437. {1:~ }|
  438. {1:~ }|
  439. ]], showmode={ { "recording @q", 3 } }}
  440. feed('i')
  441. screen:expect{grid=[[
  442. ^ |
  443. {1:~ }|
  444. {1:~ }|
  445. {1:~ }|
  446. {1:~ }|
  447. ]], showmode={ { "-- INSERT --recording @q", 3 } }}
  448. feed('<esc>')
  449. screen:expect{grid=[[
  450. ^ |
  451. {1:~ }|
  452. {1:~ }|
  453. {1:~ }|
  454. {1:~ }|
  455. ]], showmode={ { "recording @q", 3 } }}
  456. feed('q')
  457. screen:expect([[
  458. ^ |
  459. {1:~ }|
  460. {1:~ }|
  461. {1:~ }|
  462. {1:~ }|
  463. ]])
  464. end)
  465. it('shows macro-recording message with &noshowmode', function()
  466. command("set noshowmode")
  467. feed('qq')
  468. -- also check mode to avoid immediate success
  469. screen:expect{grid=[[
  470. ^ |
  471. {1:~ }|
  472. {1:~ }|
  473. {1:~ }|
  474. {1:~ }|
  475. ]], showmode={ { "recording @q", 3 } }, mode="normal"}
  476. feed('i')
  477. screen:expect{grid=[[
  478. ^ |
  479. {1:~ }|
  480. {1:~ }|
  481. {1:~ }|
  482. {1:~ }|
  483. ]], showmode={ { "recording @q", 3 } }, mode="insert"}
  484. feed('<esc>')
  485. screen:expect{grid=[[
  486. ^ |
  487. {1:~ }|
  488. {1:~ }|
  489. {1:~ }|
  490. {1:~ }|
  491. ]], showmode={ { "recording @q", 3 } }, mode="normal"}
  492. feed('q')
  493. screen:expect{grid=[[
  494. ^ |
  495. {1:~ }|
  496. {1:~ }|
  497. {1:~ }|
  498. {1:~ }|
  499. ]], mode="normal"}
  500. end)
  501. it('supports &showcmd and &ruler', function()
  502. command('set showcmd ruler')
  503. screen:expect{grid=[[
  504. ^ |
  505. {1:~ }|
  506. {1:~ }|
  507. {1:~ }|
  508. {1:~ }|
  509. ]], ruler={ { "0,0-1 All" } }}
  510. feed('i')
  511. screen:expect{grid=[[
  512. ^ |
  513. {1:~ }|
  514. {1:~ }|
  515. {1:~ }|
  516. {1:~ }|
  517. ]], showmode={ { "-- INSERT --", 3 } }, ruler={ { "0,1 All" } }}
  518. feed('abcde<cr>12345<esc>')
  519. screen:expect{grid=[[
  520. abcde |
  521. 1234^5 |
  522. {1:~ }|
  523. {1:~ }|
  524. {1:~ }|
  525. ]], ruler={ { "2,5 All" } }}
  526. feed('d')
  527. screen:expect{grid=[[
  528. abcde |
  529. 1234^5 |
  530. {1:~ }|
  531. {1:~ }|
  532. {1:~ }|
  533. ]], showcmd={ { "d" } }, ruler={ { "2,5 All" } }}
  534. feed('<esc>^')
  535. screen:expect{grid=[[
  536. abcde |
  537. ^12345 |
  538. {1:~ }|
  539. {1:~ }|
  540. {1:~ }|
  541. ]], ruler={ { "2,1 All" } }}
  542. feed('d')
  543. screen:expect{grid=[[
  544. abcde |
  545. ^12345 |
  546. {1:~ }|
  547. {1:~ }|
  548. {1:~ }|
  549. ]], showcmd={ { "d" } }, ruler={ { "2,1 All" } }}
  550. feed('i')
  551. screen:expect{grid=[[
  552. abcde |
  553. ^12345 |
  554. {1:~ }|
  555. {1:~ }|
  556. {1:~ }|
  557. ]], showcmd={ { "di" } }, ruler={ { "2,1 All" } }}
  558. feed('w')
  559. screen:expect{grid=[[
  560. abcde |
  561. ^ |
  562. {1:~ }|
  563. {1:~ }|
  564. {1:~ }|
  565. ]], ruler={ { "2,0-1 All" } }}
  566. -- when ruler is part of statusline it is not externalized.
  567. -- this will be added as part of future ext_statusline support
  568. command("set laststatus=2")
  569. screen:expect([[
  570. abcde |
  571. ^ |
  572. {1:~ }|
  573. {1:~ }|
  574. {6:<o Name] [+] 2,0-1 All}|
  575. ]])
  576. end)
  577. it('keeps history of message of different kinds', function()
  578. feed(':echomsg "howdy"<cr>')
  579. screen:expect{grid=[[
  580. ^ |
  581. {1:~ }|
  582. {1:~ }|
  583. {1:~ }|
  584. {1:~ }|
  585. ]], messages={{
  586. content = {{ "howdy" }}, kind = "echomsg"}
  587. }}
  588. -- always test a message without kind. If this one gets promoted to a
  589. -- category, add a new message without kind.
  590. feed('<c-c>')
  591. screen:expect{grid=[[
  592. ^ |
  593. {1:~ }|
  594. {1:~ }|
  595. {1:~ }|
  596. {1:~ }|
  597. ]], messages={{
  598. content = {{ "Type :qa and press <Enter> to exit Nvim" }},
  599. kind = ""}
  600. }}
  601. feed(':echoerr "bork"<cr>')
  602. screen:expect{grid=[[
  603. ^ |
  604. {1:~ }|
  605. {1:~ }|
  606. {1:~ }|
  607. {1:~ }|
  608. ]], messages={{
  609. content = {{ "bork", 2 }}, kind = "echoerr"}
  610. }}
  611. feed(':echo "xyz"<cr>')
  612. screen:expect{grid=[[
  613. ^ |
  614. {1:~ }|
  615. {1:~ }|
  616. {1:~ }|
  617. {1:~ }|
  618. ]], messages={{
  619. content = {{ "xyz" }}, kind = "echo"}
  620. }}
  621. feed(':call nosuchfunction()<cr>')
  622. screen:expect{grid=[[
  623. ^ |
  624. {1:~ }|
  625. {1:~ }|
  626. {1:~ }|
  627. {1:~ }|
  628. ]], messages={{
  629. content = {{ "E117: Unknown function: nosuchfunction", 2 }},
  630. kind = "emsg"}
  631. }}
  632. feed(':messages<cr>')
  633. screen:expect{grid=[[
  634. ^ |
  635. {1:~ }|
  636. {1:~ }|
  637. {1:~ }|
  638. {1:~ }|
  639. ]], messages={
  640. {kind="echomsg", content={{"howdy"}}},
  641. {kind="", content={{"Type :qa and press <Enter> to exit Nvim"}}},
  642. {kind="echoerr", content={{"bork", 2}}},
  643. {kind="emsg", content={{"E117: Unknown function: nosuchfunction", 2}}}
  644. }}
  645. end)
  646. it('implies ext_cmdline and ignores cmdheight', function()
  647. eq(0, eval('&cmdheight'))
  648. feed(':set cmdheight=1')
  649. screen:expect{grid=[[
  650. ^ |
  651. {1:~ }|
  652. {1:~ }|
  653. {1:~ }|
  654. {1:~ }|
  655. ]], cmdline={{
  656. content = { { "set cmdheight=1" } },
  657. firstc = ":",
  658. pos = 15 }
  659. }}
  660. feed('<cr>')
  661. screen:expect([[
  662. ^ |
  663. {1:~ }|
  664. {1:~ }|
  665. {1:~ }|
  666. {1:~ }|
  667. ]])
  668. eq(0, eval('&cmdheight'))
  669. -- normally this would be an error
  670. feed(':set cmdheight=0')
  671. screen:expect{grid=[[
  672. ^ |
  673. {1:~ }|
  674. {1:~ }|
  675. {1:~ }|
  676. {1:~ }|
  677. ]], cmdline={{
  678. content = { { "set cmdheight=0" } },
  679. firstc = ":",
  680. pos = 15 }
  681. }}
  682. feed('<cr>')
  683. screen:expect([[
  684. ^ |
  685. {1:~ }|
  686. {1:~ }|
  687. {1:~ }|
  688. {1:~ }|
  689. ]])
  690. eq(0, eval('&cmdheight'))
  691. end)
  692. it('supports multiline messages from lua', function()
  693. feed(':lua error("such\\nmultiline\\nerror")<cr>')
  694. screen:expect{grid=[[
  695. ^ |
  696. {1:~ }|
  697. {1:~ }|
  698. {1:~ }|
  699. {1:~ }|
  700. ]], messages={{
  701. content = {{'E5108: Error executing lua [string ":lua"]:1: such\nmultiline\nerror', 2}},
  702. kind = "lua_error"
  703. }}}
  704. end)
  705. it('supports multiline messages from rpc', function()
  706. feed(':call rpcrequest(1, "test_method")<cr>')
  707. screen:expect{grid=[[
  708. ^ |
  709. {1:~ }|
  710. {1:~ }|
  711. {1:~ }|
  712. {1:~ }|
  713. ]], messages={{
  714. content = {{"Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 2}},
  715. kind = "rpc_error"
  716. }}, request_cb=function (name)
  717. if name == "test_method" then
  718. set_method_error("complete\nerror\n\nmessage")
  719. end
  720. end}
  721. end)
  722. it('wildmode=list', function()
  723. screen:try_resize(25, 7)
  724. screen:set_option('ext_popupmenu', false)
  725. command('set wildmenu wildmode=list')
  726. feed(':set wildm<tab>')
  727. screen:expect{grid=[[
  728. ^ |
  729. {1:~ }|
  730. {1:~ }|
  731. {1:~ }|
  732. {1:~ }|
  733. {1:~ }|
  734. {1:~ }|
  735. ]], messages={{
  736. content = {{'wildmenu wildmode'}},
  737. kind = '',
  738. }},
  739. cmdline={{
  740. firstc = ':',
  741. content = {{ 'set wildm' }},
  742. pos = 9,
  743. }}}
  744. end)
  745. it('hides prompt_for_number messages', function()
  746. command('set spell')
  747. feed('ihelllo<esc>')
  748. feed('z=')
  749. screen:expect{grid=[[
  750. {9:helllo} |
  751. {1:~ }|
  752. {1:~ }|
  753. {1:~ }|
  754. {1:^~ }|
  755. ]], messages={
  756. {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ' } }, kind = ""}
  757. }}
  758. feed('1')
  759. screen:expect{grid=[[
  760. {9:helllo} |
  761. {1:~ }|
  762. {1:~ }|
  763. {1:~ }|
  764. {1:^~ }|
  765. ]], messages={
  766. {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ' } }, kind = ""},
  767. { content = { { "1" } }, kind = "" }
  768. }}
  769. feed('<cr>')
  770. screen:expect{grid=[[
  771. ^Hello |
  772. {1:~ }|
  773. {1:~ }|
  774. {1:~ }|
  775. {1:~ }|
  776. ]]}
  777. end)
  778. end)
  779. describe('ui/builtin messages', function()
  780. local screen
  781. before_each(function()
  782. clear()
  783. screen = Screen.new(60, 7)
  784. screen:attach({rgb=true, ext_popupmenu=true})
  785. screen:set_default_attr_ids({
  786. [1] = {bold = true, foreground = Screen.colors.Blue1},
  787. [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  788. [3] = {bold = true, reverse = true},
  789. [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
  790. [5] = {foreground = Screen.colors.Blue1},
  791. [6] = {bold = true, foreground = Screen.colors.Magenta},
  792. [7] = {background = Screen.colors.Grey20},
  793. [8] = {reverse = true},
  794. [9] = {background = Screen.colors.LightRed}
  795. })
  796. end)
  797. it('supports multiline messages from rpc', function()
  798. feed(':call rpcrequest(1, "test_method")<cr>')
  799. screen:expect{grid=[[
  800. {3: }|
  801. {2:Error invoking 'test_method' on channel 1:} |
  802. {2:complete} |
  803. {2:error} |
  804. |
  805. {2:message} |
  806. {4:Press ENTER or type command to continue}^ |
  807. ]], request_cb=function (name)
  808. if name == "test_method" then
  809. set_method_error("complete\nerror\n\nmessage")
  810. end
  811. end}
  812. end)
  813. it(':hi Group output', function()
  814. screen:try_resize(70,7)
  815. feed(':hi ErrorMsg<cr>')
  816. screen:expect([[
  817. |
  818. {1:~ }|
  819. {1:~ }|
  820. {3: }|
  821. :hi ErrorMsg |
  822. ErrorMsg {2:xxx} {5:ctermfg=}15 {5:ctermbg=}1 {5:guifg=}White {5:guibg=}Red |
  823. {4:Press ENTER or type command to continue}^ |
  824. ]])
  825. feed('<cr>')
  826. screen:try_resize(30,7)
  827. feed(':hi ErrorMsg<cr>')
  828. screen:expect([[
  829. :hi ErrorMsg |
  830. ErrorMsg {2:xxx} {5:ctermfg=}15 |
  831. {5:ctermbg=}1 |
  832. {5:guifg=}White|
  833. {5:guibg=}Red |
  834. {4:Press ENTER or type command to}|
  835. {4: continue}^ |
  836. ]])
  837. feed('<cr>')
  838. -- screen size doesn't affect internal output #10285
  839. eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red',
  840. meths.exec("hi ErrorMsg", true))
  841. end)
  842. it(':syntax list langGroup output', function()
  843. command("syntax on")
  844. command("set syntax=vim")
  845. screen:try_resize(110,7)
  846. feed(':syntax list vimComment<cr>')
  847. screen:expect([[
  848. {6:--- Syntax items ---} |
  849. vimComment {5:xxx} {5:match} /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 {5:excludenl} {5:contains}=@vimCommentGroup,vimCommentString |
  850. |
  851. {5:match} /\<endif\s\+".*$/ms=s+5,lc=5 {5:contains}=@vimCommentGroup,vimCommentString |
  852. {5:match} /\<else\s\+".*$/ms=s+4,lc=4 {5:contains}=@vimCommentGroup,vimCommentString |
  853. {5:links to} Comment |
  854. {4:Press ENTER or type command to continue}^ |
  855. ]])
  856. feed('<cr>')
  857. screen:try_resize(55,7)
  858. feed(':syntax list vimComment<cr>')
  859. screen:expect([[
  860. |
  861. {5:match} /\<endif\s\+".*$/ms=s+5,lc=5 |
  862. {5:contains}=@vimCommentGroup,vimCommentString |
  863. {5:match} /\<else\s\+".*$/ms=s+4,lc=4 {5:c}|
  864. {5:ontains}=@vimCommentGroup,vimCommentString |
  865. {5:links to} Comment |
  866. {4:Press ENTER or type command to continue}^ |
  867. ]])
  868. feed('<cr>')
  869. -- ignore final whitespace inside string
  870. -- luacheck: push ignore
  871. eq([[--- Syntax items ---
  872. vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vimCommentGroup,vimCommentString
  873. match /\<endif\s\+".*$/ms=s+5,lc=5 contains=@vimCommentGroup,vimCommentString
  874. match /\<else\s\+".*$/ms=s+4,lc=4 contains=@vimCommentGroup,vimCommentString
  875. links to Comment]],
  876. meths.exec('syntax list vimComment', true))
  877. -- luacheck: pop
  878. end)
  879. it('supports ruler with laststatus=0', function()
  880. command("set ruler laststatus=0")
  881. screen:expect{grid=[[
  882. ^ |
  883. {1:~ }|
  884. {1:~ }|
  885. {1:~ }|
  886. {1:~ }|
  887. {1:~ }|
  888. 0,0-1 All |
  889. ]]}
  890. command("hi MsgArea guibg=#333333")
  891. screen:expect{grid=[[
  892. ^ |
  893. {1:~ }|
  894. {1:~ }|
  895. {1:~ }|
  896. {1:~ }|
  897. {1:~ }|
  898. {7: 0,0-1 All }|
  899. ]]}
  900. command("set rulerformat=%15(%c%V\\ %p%%%)")
  901. screen:expect{grid=[[
  902. ^ |
  903. {1:~ }|
  904. {1:~ }|
  905. {1:~ }|
  906. {1:~ }|
  907. {1:~ }|
  908. {7: 0,0-1 100% }|
  909. ]]}
  910. end)
  911. it('supports echo with CRLF line separators', function()
  912. feed(':echo "line 1\\r\\nline 2"<cr>')
  913. screen:expect{grid=[[
  914. |
  915. {1:~ }|
  916. {1:~ }|
  917. {3: }|
  918. line 1 |
  919. line 2 |
  920. {4:Press ENTER or type command to continue}^ |
  921. ]]}
  922. feed('<cr>:echo "abc\\rz"<cr>')
  923. screen:expect{grid=[[
  924. ^ |
  925. {1:~ }|
  926. {1:~ }|
  927. {1:~ }|
  928. {1:~ }|
  929. {1:~ }|
  930. zbc |
  931. ]]}
  932. end)
  933. it('redraws NOT_VALID correctly after message', function()
  934. -- edge case: only one window was set NOT_VALID. Orginal report
  935. -- used :make, but fake it using one command to set the current
  936. -- window NOT_VALID and another to show a long message.
  937. command("set more")
  938. feed(':new<cr><c-w><c-w>')
  939. screen:expect{grid=[[
  940. |
  941. {1:~ }|
  942. {8:[No Name] }|
  943. ^ |
  944. {1:~ }|
  945. {3:[No Name] }|
  946. :new |
  947. ]]}
  948. feed(':set colorcolumn=10 | digraphs<cr>')
  949. screen:expect{grid=[[
  950. :set colorcolumn=10 | digraphs |
  951. NU {5:^@} 10 SH {5:^A} 1 SX {5:^B} 2 EX {5:^C} 3 |
  952. ET {5:^D} 4 EQ {5:^E} 5 AK {5:^F} 6 BL {5:^G} 7 |
  953. BS {5:^H} 8 HT {5:^I} 9 LF {5:^@} 10 VT {5:^K} 11 |
  954. FF {5:^L} 12 CR {5:^M} 13 SO {5:^N} 14 SI {5:^O} 15 |
  955. DL {5:^P} 16 D1 {5:^Q} 17 D2 {5:^R} 18 D3 {5:^S} 19 |
  956. {4:-- More --}^ |
  957. ]]}
  958. feed('q')
  959. screen:expect{grid=[[
  960. |
  961. {1:~ }|
  962. {8:[No Name] }|
  963. ^ {9: } |
  964. {1:~ }|
  965. {3:[No Name] }|
  966. |
  967. ]]}
  968. -- edge case: just covers statusline
  969. feed(':set colorcolumn=5 | lua error("x\\n\\nx")<cr>')
  970. screen:expect{grid=[[
  971. |
  972. {1:~ }|
  973. {3: }|
  974. {2:E5108: Error executing lua [string ":lua"]:1: x} |
  975. |
  976. {2:x} |
  977. {4:Press ENTER or type command to continue}^ |
  978. ]]}
  979. feed('<cr>')
  980. screen:expect{grid=[[
  981. |
  982. {1:~ }|
  983. {8:[No Name] }|
  984. ^ {9: } |
  985. {1:~ }|
  986. {3:[No Name] }|
  987. |
  988. ]]}
  989. -- edge case: just covers lowest window line
  990. feed(':set colorcolumn=5 | lua error("x\\n\\n\\nx")<cr>')
  991. screen:expect{grid=[[
  992. |
  993. {3: }|
  994. {2:E5108: Error executing lua [string ":lua"]:1: x} |
  995. |
  996. |
  997. {2:x} |
  998. {4:Press ENTER or type command to continue}^ |
  999. ]]}
  1000. feed('<cr>')
  1001. screen:expect{grid=[[
  1002. |
  1003. {1:~ }|
  1004. {8:[No Name] }|
  1005. ^ {9: } |
  1006. {1:~ }|
  1007. {3:[No Name] }|
  1008. |
  1009. ]]}
  1010. end)
  1011. end)
  1012. describe('ui/ext_messages', function()
  1013. local screen
  1014. before_each(function()
  1015. clear{args_rm={'--headless'}, args={"--cmd", "set shortmess-=I"}}
  1016. screen = Screen.new(80, 24)
  1017. screen:attach({rgb=true, ext_messages=true, ext_popupmenu=true})
  1018. screen:set_default_attr_ids({
  1019. [1] = {bold = true, foreground = Screen.colors.Blue1},
  1020. [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  1021. [3] = {bold = true},
  1022. [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
  1023. [5] = {foreground = Screen.colors.Blue1},
  1024. })
  1025. end)
  1026. it('supports intro screen', function()
  1027. -- intro message is not externalized. But check that it still works.
  1028. -- Note parts of it depends on version or is indeterministic. We ignore those parts.
  1029. screen:expect([[
  1030. ^ |
  1031. {1:~ }|
  1032. {1:~ }|
  1033. {1:~ }|
  1034. {1:~ }|
  1035. {1:~ }|
  1036. {MATCH:.*}|
  1037. {1:~ }|
  1038. {1:~ }Nvim is open source and freely distributable{1: }|
  1039. {1:~ }https://neovim.io/#chat{1: }|
  1040. {1:~ }|
  1041. {1:~ }type :help nvim{5:<Enter>} if you are new! {1: }|
  1042. {1:~ }type :checkhealth{5:<Enter>} to optimize Nvim{1: }|
  1043. {1:~ }type :q{5:<Enter>} to exit {1: }|
  1044. {1:~ }type :help{5:<Enter>} for help {1: }|
  1045. {1:~ }|
  1046. {MATCH:.*}|
  1047. {MATCH:.*}|
  1048. {1:~ }|
  1049. {1:~ }|
  1050. {1:~ }|
  1051. {1:~ }|
  1052. {1:~ }|
  1053. {1:~ }|
  1054. ]])
  1055. feed("<c-l>")
  1056. screen:expect([[
  1057. ^ |
  1058. {1:~ }|
  1059. {1:~ }|
  1060. {1:~ }|
  1061. {1:~ }|
  1062. {1:~ }|
  1063. {1:~ }|
  1064. {1:~ }|
  1065. {1:~ }|
  1066. {1:~ }|
  1067. {1:~ }|
  1068. {1:~ }|
  1069. {1:~ }|
  1070. {1:~ }|
  1071. {1:~ }|
  1072. {1:~ }|
  1073. {1:~ }|
  1074. {1:~ }|
  1075. {1:~ }|
  1076. {1:~ }|
  1077. {1:~ }|
  1078. {1:~ }|
  1079. {1:~ }|
  1080. {1:~ }|
  1081. ]])
  1082. feed(":intro<cr>")
  1083. screen:expect{grid=[[
  1084. |
  1085. |
  1086. |
  1087. |
  1088. |
  1089. |
  1090. {MATCH:.*}|
  1091. |
  1092. Nvim is open source and freely distributable |
  1093. https://neovim.io/#chat |
  1094. |
  1095. type :help nvim{5:<Enter>} if you are new! |
  1096. type :checkhealth{5:<Enter>} to optimize Nvim |
  1097. type :q{5:<Enter>} to exit |
  1098. type :help{5:<Enter>} for help |
  1099. |
  1100. {MATCH:.*}|
  1101. {MATCH:.*}|
  1102. |
  1103. |
  1104. |
  1105. |
  1106. |
  1107. |
  1108. ]], messages={
  1109. {content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" }
  1110. }}
  1111. end)
  1112. end)
  1113. describe('ui/msg_puts_printf', function()
  1114. it('output multibyte characters correctly', function()
  1115. local screen
  1116. local cmd = ''
  1117. local locale_dir = test_build_dir..'/share/locale/ja/LC_MESSAGES'
  1118. clear({env={LANG='ja_JP.UTF-8'}})
  1119. screen = Screen.new(25, 5)
  1120. screen:attach()
  1121. if iswin() then
  1122. if os.execute('chcp 932 > NUL 2>&1') ~= 0 then
  1123. pending('missing japanese language features', function() end)
  1124. return
  1125. else
  1126. cmd = 'chcp 932 > NULL & '
  1127. end
  1128. else
  1129. if (exc_exec('lang ja_JP.UTF-8') ~= 0) then
  1130. pending('Locale ja_JP.UTF-8 not supported', function() end)
  1131. return
  1132. elseif helpers.isCI() then
  1133. -- Fails non--Windows CI. Message catalog direcotry issue?
  1134. pending('fails on unix CI', function() end)
  1135. return
  1136. end
  1137. end
  1138. os.execute('cmake -E make_directory '..locale_dir)
  1139. os.execute('cmake -E copy '..test_build_dir..'/src/nvim/po/ja.mo '..locale_dir..'/nvim.mo')
  1140. cmd = cmd..'"'..nvim_prog..'" -u NONE -i NONE -Es -V1'
  1141. command([[call termopen(']]..cmd..[[')]])
  1142. screen:expect([[
  1143. ^Exモードに入ります. ノー |
  1144. マルモードに戻るには"visu|
  1145. al"と入力してください. |
  1146. : |
  1147. |
  1148. ]])
  1149. os.execute('cmake -E remove_directory '..test_build_dir..'/share')
  1150. end)
  1151. end)
  1152. describe('pager', function()
  1153. local screen
  1154. before_each(function()
  1155. clear()
  1156. screen = Screen.new(35, 8)
  1157. screen:attach()
  1158. screen:set_default_attr_ids({
  1159. [1] = {bold = true, foreground = Screen.colors.Blue1},
  1160. [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  1161. [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red, special=Screen.colors.Yellow},
  1162. [4] = {bold = true, foreground = Screen.colors.SeaGreen4},
  1163. [5] = {special = Screen.colors.Yellow},
  1164. [6] = {special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4},
  1165. [7] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey100},
  1166. [8] = {foreground = Screen.colors.Gray90, background = Screen.colors.Grey100},
  1167. [9] = {foreground = tonumber('0x00000c'), background = Screen.colors.Grey100},
  1168. [10] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff')},
  1169. [11] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber ('0x2b8452')},
  1170. [12] = {bold = true, reverse = true},
  1171. })
  1172. command("set more")
  1173. exec_lua('_G.x = ...', [[
  1174. Lorem ipsum dolor sit amet, consectetur
  1175. adipisicing elit, sed do eiusmod tempor
  1176. incididunt ut labore et dolore magna aliqua.
  1177. Ut enim ad minim veniam, quis nostrud xercitation
  1178. ullamco laboris nisi ut
  1179. aliquip ex ea commodo consequat.]])
  1180. end)
  1181. it('can be quit', function()
  1182. screen:try_resize(25,5)
  1183. feed(':echon join(map(range(0, &lines*10), "v:val"), "\\n")<cr>')
  1184. screen:expect{grid=[[
  1185. 0 |
  1186. 1 |
  1187. 2 |
  1188. 3 |
  1189. {4:-- More --}^ |
  1190. ]]}
  1191. feed('q')
  1192. screen:expect{grid=[[
  1193. ^ |
  1194. {1:~ }|
  1195. {1:~ }|
  1196. {1:~ }|
  1197. |
  1198. ]]}
  1199. end)
  1200. it('handles wrapped lines with line scroll', function()
  1201. feed(':lua error(_G.x)<cr>')
  1202. screen:expect{grid=[[
  1203. {2:E5108: Error executing lua [string }|
  1204. {2:":lua"]:1: Lorem ipsum dolor sit am}|
  1205. {2:et, consectetur} |
  1206. {2:adipisicing elit, sed do eiusmod te}|
  1207. {2:mpor} |
  1208. {2:incididunt ut labore et dolore magn}|
  1209. {2:a aliqua.} |
  1210. {4:-- More --}^ |
  1211. ]]}
  1212. feed('j')
  1213. screen:expect{grid=[[
  1214. {2:":lua"]:1: Lorem ipsum dolor sit am}|
  1215. {2:et, consectetur} |
  1216. {2:adipisicing elit, sed do eiusmod te}|
  1217. {2:mpor} |
  1218. {2:incididunt ut labore et dolore magn}|
  1219. {2:a aliqua.} |
  1220. {2:Ut enim ad minim veniam, quis nostr}|
  1221. {4:-- More --}^ |
  1222. ]]}
  1223. feed('k')
  1224. screen:expect{grid=[[
  1225. {2:E5108: Error executing lua [string }|
  1226. {2:":lua"]:1: Lorem ipsum dolor sit am}|
  1227. {2:et, consectetur} |
  1228. {2:adipisicing elit, sed do eiusmod te}|
  1229. {2:mpor} |
  1230. {2:incididunt ut labore et dolore magn}|
  1231. {2:a aliqua.} |
  1232. {4:-- More --}^ |
  1233. ]]}
  1234. feed('j')
  1235. screen:expect{grid=[[
  1236. {2:":lua"]:1: Lorem ipsum dolor sit am}|
  1237. {2:et, consectetur} |
  1238. {2:adipisicing elit, sed do eiusmod te}|
  1239. {2:mpor} |
  1240. {2:incididunt ut labore et dolore magn}|
  1241. {2:a aliqua.} |
  1242. {2:Ut enim ad minim veniam, quis nostr}|
  1243. {4:-- More --}^ |
  1244. ]]}
  1245. end)
  1246. it('handles wrapped lines with page scroll', function()
  1247. feed(':lua error(_G.x)<cr>')
  1248. screen:expect{grid=[[
  1249. {2:E5108: Error executing lua [string }|
  1250. {2:":lua"]:1: Lorem ipsum dolor sit am}|
  1251. {2:et, consectetur} |
  1252. {2:adipisicing elit, sed do eiusmod te}|
  1253. {2:mpor} |
  1254. {2:incididunt ut labore et dolore magn}|
  1255. {2:a aliqua.} |
  1256. {4:-- More --}^ |
  1257. ]]}
  1258. feed('d')
  1259. screen:expect{grid=[[
  1260. {2:incididunt ut labore et dolore magn}|
  1261. {2:a aliqua.} |
  1262. {2:Ut enim ad minim veniam, quis nostr}|
  1263. {2:ud xercitation} |
  1264. {2:ullamco laboris nisi ut} |
  1265. {2:aliquip ex ea commodo consequat.} |
  1266. {4:Press ENTER or type command to cont}|
  1267. {4:inue}^ |
  1268. ]]}
  1269. feed('u')
  1270. screen:expect{grid=[[
  1271. {2:E5108: Error executing lua [string }|
  1272. {2:":lua"]:1: Lorem ipsum dolor sit am}|
  1273. {2:et, consectetur} |
  1274. {2:adipisicing elit, sed do eiusmod te}|
  1275. {2:mpor} |
  1276. {2:incididunt ut labore et dolore magn}|
  1277. {2:a aliqua.} |
  1278. {4:-- More --}^ |
  1279. ]]}
  1280. feed('d')
  1281. screen:expect{grid=[[
  1282. {2:mpor} |
  1283. {2:incididunt ut labore et dolore magn}|
  1284. {2:a aliqua.} |
  1285. {2:Ut enim ad minim veniam, quis nostr}|
  1286. {2:ud xercitation} |
  1287. {2:ullamco laboris nisi ut} |
  1288. {2:aliquip ex ea commodo consequat.} |
  1289. {4:-- More --}^ |
  1290. ]]}
  1291. end)
  1292. it('handles wrapped lines with line scroll and MsgArea highlight', function()
  1293. command("hi MsgArea guisp=Yellow")
  1294. feed(':lua error(_G.x)<cr>')
  1295. screen:expect{grid=[[
  1296. {3:E5108: Error executing lua [string }|
  1297. {3:":lua"]:1: Lorem ipsum dolor sit am}|
  1298. {3:et, consectetur}{5: }|
  1299. {3:adipisicing elit, sed do eiusmod te}|
  1300. {3:mpor}{5: }|
  1301. {3:incididunt ut labore et dolore magn}|
  1302. {3:a aliqua.}{5: }|
  1303. {6:-- More --}{5:^ }|
  1304. ]]}
  1305. feed('j')
  1306. screen:expect{grid=[[
  1307. {3:":lua"]:1: Lorem ipsum dolor sit am}|
  1308. {3:et, consectetur}{5: }|
  1309. {3:adipisicing elit, sed do eiusmod te}|
  1310. {3:mpor}{5: }|
  1311. {3:incididunt ut labore et dolore magn}|
  1312. {3:a aliqua.}{5: }|
  1313. {3:Ut enim ad minim veniam, quis nostr}|
  1314. {6:-- More --}{5:^ }|
  1315. ]]}
  1316. feed('k')
  1317. screen:expect{grid=[[
  1318. {3:E5108: Error executing lua [string }|
  1319. {3:":lua"]:1: Lorem ipsum dolor sit am}|
  1320. {3:et, consectetur}{5: }|
  1321. {3:adipisicing elit, sed do eiusmod te}|
  1322. {3:mpor}{5: }|
  1323. {3:incididunt ut labore et dolore magn}|
  1324. {3:a aliqua.}{5: }|
  1325. {6:-- More --}{5:^ }|
  1326. ]]}
  1327. feed('j')
  1328. screen:expect{grid=[[
  1329. {3:":lua"]:1: Lorem ipsum dolor sit am}|
  1330. {3:et, consectetur}{5: }|
  1331. {3:adipisicing elit, sed do eiusmod te}|
  1332. {3:mpor}{5: }|
  1333. {3:incididunt ut labore et dolore magn}|
  1334. {3:a aliqua.}{5: }|
  1335. {3:Ut enim ad minim veniam, quis nostr}|
  1336. {6:-- More --}{5:^ }|
  1337. ]]}
  1338. end)
  1339. it('handles wrapped lines with page scroll and MsgArea highlight', function()
  1340. command("hi MsgArea guisp=Yellow")
  1341. feed(':lua error(_G.x)<cr>')
  1342. screen:expect{grid=[[
  1343. {3:E5108: Error executing lua [string }|
  1344. {3:":lua"]:1: Lorem ipsum dolor sit am}|
  1345. {3:et, consectetur}{5: }|
  1346. {3:adipisicing elit, sed do eiusmod te}|
  1347. {3:mpor}{5: }|
  1348. {3:incididunt ut labore et dolore magn}|
  1349. {3:a aliqua.}{5: }|
  1350. {6:-- More --}{5:^ }|
  1351. ]]}
  1352. feed('d')
  1353. screen:expect{grid=[[
  1354. {3:incididunt ut labore et dolore magn}|
  1355. {3:a aliqua.}{5: }|
  1356. {3:Ut enim ad minim veniam, quis nostr}|
  1357. {3:ud xercitation}{5: }|
  1358. {3:ullamco laboris nisi ut}{5: }|
  1359. {3:aliquip ex ea commodo consequat.}{5: }|
  1360. {6:Press ENTER or type command to cont}|
  1361. {6:inue}{5:^ }|
  1362. ]]}
  1363. feed('u')
  1364. screen:expect{grid=[[
  1365. {3:E5108: Error executing lua [string }|
  1366. {3:":lua"]:1: Lorem ipsum dolor sit am}|
  1367. {3:et, consectetur}{5: }|
  1368. {3:adipisicing elit, sed do eiusmod te}|
  1369. {3:mpor}{5: }|
  1370. {3:incididunt ut labore et dolore magn}|
  1371. {3:a aliqua.}{5: }|
  1372. {6:-- More --}{5:^ }|
  1373. ]]}
  1374. feed('d')
  1375. screen:expect{grid=[[
  1376. {3:mpor}{5: }|
  1377. {3:incididunt ut labore et dolore magn}|
  1378. {3:a aliqua.}{5: }|
  1379. {3:Ut enim ad minim veniam, quis nostr}|
  1380. {3:ud xercitation}{5: }|
  1381. {3:ullamco laboris nisi ut}{5: }|
  1382. {3:aliquip ex ea commodo consequat.}{5: }|
  1383. {6:-- More --}{5:^ }|
  1384. ]]}
  1385. end)
  1386. it('preserves MsgArea highlighting after more prompt', function()
  1387. screen:try_resize(70,6)
  1388. command("hi MsgArea guisp=Yellow")
  1389. command("map x Lorem ipsum labore et dolore magna aliqua")
  1390. command("map y adipisicing elit")
  1391. command("map z incididunt ut")
  1392. command("map a labore et dolore")
  1393. command("map b ex ea commodo")
  1394. command("map xx yy")
  1395. command("map xy yz")
  1396. feed(':map<cr>')
  1397. screen:expect{grid=[[
  1398. {5: a labore et dolore }|
  1399. {5: b ex ea commodo }|
  1400. {5: xy yz }|
  1401. {5: xx yy }|
  1402. {5: x Lorem ipsum labore et dolore magna aliqua }|
  1403. {6:-- More --}{5:^ }|
  1404. ]]}
  1405. feed('j')
  1406. screen:expect{grid=[[
  1407. {5: b ex ea commodo }|
  1408. {5: xy yz }|
  1409. {5: xx yy }|
  1410. {5: x Lorem ipsum labore et dolore magna aliqua }|
  1411. {5: y adipisicing elit }|
  1412. {6:-- More --}{5:^ }|
  1413. ]]}
  1414. feed('j')
  1415. screen:expect{grid=[[
  1416. {5: xy yz }|
  1417. {5: xx yy }|
  1418. {5: x Lorem ipsum labore et dolore magna aliqua }|
  1419. {5: y adipisicing elit }|
  1420. {5: z incididunt ut }|
  1421. {6:Press ENTER or type command to continue}{5:^ }|
  1422. ]]}
  1423. end)
  1424. it('clears "-- more --" message', function()
  1425. command("hi MsgArea guisp=Yellow blend=10")
  1426. feed(':echon join(range(20), "\\n")<cr>')
  1427. screen:expect{grid=[[
  1428. {7:0}{8: }|
  1429. {9:1}{10: }|
  1430. {9:2}{10: }|
  1431. {9:3}{10: }|
  1432. {9:4}{10: }|
  1433. {9:5}{10: }|
  1434. {9:6}{10: }|
  1435. {11:--}{8: }{11:More}{8: }{11:--}{8:^ }|
  1436. ]]}
  1437. feed('j')
  1438. screen:expect{grid=[[
  1439. {7:1}{8: }|
  1440. {9:2}{10: }|
  1441. {9:3}{10: }|
  1442. {9:4}{10: }|
  1443. {9:5}{10: }|
  1444. {9:6}{10: }|
  1445. {9:7}{10: }|
  1446. {11:--}{8: }{11:More}{8: }{11:--}{8:^ }|
  1447. ]]}
  1448. feed('k')
  1449. screen:expect{grid=[[
  1450. {7:0}{8: }{7:)}{8: }|
  1451. {9:1}{10: }|
  1452. {9:2}{10: }|
  1453. {9:3}{10: }|
  1454. {9:4}{10: }|
  1455. {9:5}{10: }|
  1456. {9:6}{10: }|
  1457. {11:--}{8: }{11:More}{8: }{11:--}{8:^ }|
  1458. ]]}
  1459. feed('j')
  1460. screen:expect{grid=[[
  1461. {7:1}{8: }|
  1462. {9:2}{10: }|
  1463. {9:3}{10: }|
  1464. {9:4}{10: }|
  1465. {9:5}{10: }|
  1466. {9:6}{10: }|
  1467. {9:7}{10: }|
  1468. {11:--}{8: }{11:More}{8: }{11:--}{8:^ }|
  1469. ]]}
  1470. end)
  1471. it('with :!cmd does not crash on resize', function()
  1472. feed(':!sleep 1<cr>')
  1473. screen:expect{grid=[[
  1474. |
  1475. {1:~ }|
  1476. {1:~ }|
  1477. {1:~ }|
  1478. {1:~ }|
  1479. {12: }|
  1480. :!sleep 1 |
  1481. |
  1482. ]]}
  1483. -- not processed while command is executing
  1484. async_meths.ui_try_resize(35, 5)
  1485. -- TODO(bfredl): ideally it should be processed just
  1486. -- before the "press ENTER" prompt though
  1487. screen:expect{grid=[[
  1488. |
  1489. {1:~ }|
  1490. {1:~ }|
  1491. {12: }|
  1492. :!sleep 1 |
  1493. |
  1494. {4:Press ENTER or type command to cont}|
  1495. {4:inue}^ |
  1496. ]]}
  1497. feed('<cr>')
  1498. screen:expect{grid=[[
  1499. ^ |
  1500. {1:~ }|
  1501. {1:~ }|
  1502. {1:~ }|
  1503. |
  1504. ]]}
  1505. end)
  1506. it('can be resized', function()
  1507. feed(':lua error(_G.x)<cr>')
  1508. screen:expect{grid=[[
  1509. {2:E5108: Error executing lua [string }|
  1510. {2:":lua"]:1: Lorem ipsum dolor sit am}|
  1511. {2:et, consectetur} |
  1512. {2:adipisicing elit, sed do eiusmod te}|
  1513. {2:mpor} |
  1514. {2:incididunt ut labore et dolore magn}|
  1515. {2:a aliqua.} |
  1516. {4:-- More --}^ |
  1517. ]]}
  1518. -- responds to resize, but text is not reflown
  1519. screen:try_resize(45, 5)
  1520. screen:expect{grid=[[
  1521. {2:adipisicing elit, sed do eiusmod te} |
  1522. {2:mpor} |
  1523. {2:incididunt ut labore et dolore magn} |
  1524. {2:a aliqua.} |
  1525. {4:-- More --}^ |
  1526. ]]}
  1527. -- can create empty space, as the command hasn't output the text below yet.
  1528. -- text is not reflown; existing lines get cut
  1529. screen:try_resize(30, 12)
  1530. screen:expect{grid=[[
  1531. {2:E5108: Error executing lua [st}|
  1532. {2:":lua"]:1: Lorem ipsum dolor s}|
  1533. {2:et, consectetur} |
  1534. {2:adipisicing elit, sed do eiusm}|
  1535. {2:mpore} |
  1536. {2:incididunt ut labore et dolore}|
  1537. {2:a aliqua.} |
  1538. |
  1539. |
  1540. |
  1541. |
  1542. {4:-- More --}^ |
  1543. ]]}
  1544. -- continues in a mostly consistent state, but only new lines are
  1545. -- wrapped at the new screen size.
  1546. feed('<cr>')
  1547. screen:expect{grid=[[
  1548. {2:et, consectetur} |
  1549. {2:adipisicing elit, sed do eiusm}|
  1550. {2:mpore} |
  1551. {2:incididunt ut labore et dolore}|
  1552. {2:a aliqua.} |
  1553. {2:Ut enim ad minim veniam, quis }|
  1554. {2:nostrud xercitation} |
  1555. {2:ullamco laboris nisi ut} |
  1556. {2:aliquip ex ea commodo consequa}|
  1557. {2:t.} |
  1558. {4:Press ENTER or type command to}|
  1559. {4: continue}^ |
  1560. ]]}
  1561. feed('q')
  1562. screen:expect{grid=[[
  1563. ^ |
  1564. {1:~ }|
  1565. {1:~ }|
  1566. {1:~ }|
  1567. {1:~ }|
  1568. {1:~ }|
  1569. {1:~ }|
  1570. {1:~ }|
  1571. {1:~ }|
  1572. {1:~ }|
  1573. {1:~ }|
  1574. |
  1575. ]]}
  1576. end)
  1577. end)