messages_spec.lua 85 KB

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