syntax_conceal_spec.lua 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local clear, feed, command = helpers.clear, helpers.feed, helpers.command
  4. local eq = helpers.eq
  5. local insert = helpers.insert
  6. describe('Screen', function()
  7. local screen
  8. before_each(function()
  9. clear()
  10. screen = Screen.new(nil,10)
  11. screen:attach()
  12. screen:set_default_attr_ids( {
  13. [0] = {bold=true, foreground=Screen.colors.Blue},
  14. [1] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray},
  15. [2] = {bold = true, reverse = true},
  16. [3] = {reverse = true},
  17. [4] = {bold = true},
  18. [5] = {background = Screen.colors.Yellow},
  19. [6] = {background = Screen.colors.LightGrey},
  20. } )
  21. end)
  22. describe("match and conceal", function()
  23. before_each(function()
  24. command("let &conceallevel=1")
  25. end)
  26. describe("multiple", function()
  27. before_each(function()
  28. insert([[
  29. &&
  30. &&
  31. &&
  32. &&
  33. &&
  34. &&
  35. ]])
  36. command("syn match dAmpersand '[&][&]' conceal cchar=∧")
  37. end)
  38. it("double characters.", function()
  39. screen:expect([[
  40. {1:∧} |
  41. {1:∧} |
  42. {1:∧} |
  43. {1:∧} |
  44. {1:∧} |
  45. {1:∧} |
  46. ^ |
  47. {0:~ }|
  48. {0:~ }|
  49. |
  50. ]])
  51. end)
  52. it('double characters and move the cursor one line up.', function()
  53. feed("k")
  54. screen:expect([[
  55. {1:∧} |
  56. {1:∧} |
  57. {1:∧} |
  58. {1:∧} |
  59. {1:∧} |
  60. ^&& |
  61. |
  62. {0:~ }|
  63. {0:~ }|
  64. |
  65. ]])
  66. end)
  67. it('double characters and move the cursor to the beginning of the file.', function()
  68. feed("gg")
  69. screen:expect([[
  70. ^&& |
  71. {1:∧} |
  72. {1:∧} |
  73. {1:∧} |
  74. {1:∧} |
  75. {1:∧} |
  76. |
  77. {0:~ }|
  78. {0:~ }|
  79. |
  80. ]])
  81. end)
  82. it('double characters and move the cursor to the second line in the file.', function()
  83. feed("ggj")
  84. screen:expect([[
  85. {1:∧} |
  86. ^&& |
  87. {1:∧} |
  88. {1:∧} |
  89. {1:∧} |
  90. {1:∧} |
  91. |
  92. {0:~ }|
  93. {0:~ }|
  94. |
  95. ]])
  96. end)
  97. it('double characters and then move the cursor to the beginning of the file and back to the end of the file.', function()
  98. feed("ggG")
  99. screen:expect([[
  100. {1:∧} |
  101. {1:∧} |
  102. {1:∧} |
  103. {1:∧} |
  104. {1:∧} |
  105. {1:∧} |
  106. ^ |
  107. {0:~ }|
  108. {0:~ }|
  109. |
  110. ]])
  111. end)
  112. end) -- multiple
  113. it("keyword instances in initially in the document.", function()
  114. feed("2ilambda<cr><ESC>")
  115. command("let &conceallevel=1")
  116. command("syn keyword kLambda lambda conceal cchar=λ")
  117. screen:expect([[
  118. {1:λ} |
  119. {1:λ} |
  120. ^ |
  121. {0:~ }|
  122. {0:~ }|
  123. {0:~ }|
  124. {0:~ }|
  125. {0:~ }|
  126. {0:~ }|
  127. |
  128. ]])
  129. end) -- Keyword
  130. describe("regions in the document", function()
  131. before_each(function()
  132. feed("2")
  133. insert("<r> a region of text </r>\n")
  134. command("let &conceallevel=1")
  135. end)
  136. it('initially and conceal it.', function()
  137. command("syn region rText start='<r>' end='</r>' conceal cchar=R")
  138. screen:expect([[
  139. {1:R} |
  140. {1:R} |
  141. ^ |
  142. {0:~ }|
  143. {0:~ }|
  144. {0:~ }|
  145. {0:~ }|
  146. {0:~ }|
  147. {0:~ }|
  148. |
  149. ]])
  150. end)
  151. it('initially and conceal its start tag and end tag.', function()
  152. -- concealends has a known bug (todo.txt) where the first match won't
  153. -- be replaced with cchar.
  154. command("syn region rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-")
  155. screen:expect([[
  156. {1: } a region of text {1:-} |
  157. {1: } a region of text {1:-} |
  158. ^ |
  159. {0:~ }|
  160. {0:~ }|
  161. {0:~ }|
  162. {0:~ }|
  163. {0:~ }|
  164. {0:~ }|
  165. |
  166. ]])
  167. end)
  168. it('that are nested and conceal the nested region\'s start and end tags.', function()
  169. command("syn region rText contains=rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-")
  170. insert("<r> A region with <r> a nested <r> nested region.</r> </r> </r>\n")
  171. screen:expect([[
  172. {1: } a region of text {1:-} |
  173. {1: } a region of text {1:-} |
  174. {1: } A region with {1: } a nested {1: } nested region.{1:-} |
  175. {1:-} {1:-} |
  176. ^ |
  177. {0:~ }|
  178. {0:~ }|
  179. {0:~ }|
  180. {0:~ }|
  181. |
  182. ]])
  183. end)
  184. end) -- regions in the document
  185. describe("a region of text", function()
  186. before_each(function()
  187. command("syntax conceal on")
  188. feed("2")
  189. insert("<r> a region of text </r>\n")
  190. command("syn region rText start='<r>' end='</r>' cchar=-")
  191. end)
  192. it("and turn on implicit concealing", function()
  193. screen:expect([[
  194. {1:-} |
  195. {1:-} |
  196. ^ |
  197. {0:~ }|
  198. {0:~ }|
  199. {0:~ }|
  200. {0:~ }|
  201. {0:~ }|
  202. {0:~ }|
  203. |
  204. ]])
  205. end)
  206. it("and then turn on, then off, and then back on implicit concealing.", function()
  207. command("syntax conceal off")
  208. feed("2")
  209. insert("<i> italian text </i>\n")
  210. command("syn region iText start='<i>' end='</i>' cchar=*")
  211. screen:expect([[
  212. {1:-} |
  213. {1:-} |
  214. <i> italian text </i> |
  215. <i> italian text </i> |
  216. ^ |
  217. {0:~ }|
  218. {0:~ }|
  219. {0:~ }|
  220. {0:~ }|
  221. |
  222. ]])
  223. command("syntax conceal on")
  224. command("syn region iText start='<i>' end='</i>' cchar=*")
  225. screen:expect([[
  226. {1:-} |
  227. {1:-} |
  228. {1:*} |
  229. {1:*} |
  230. ^ |
  231. {0:~ }|
  232. {0:~ }|
  233. {0:~ }|
  234. {0:~ }|
  235. |
  236. ]])
  237. end)
  238. end) -- a region of text (implicit concealing)
  239. end) -- match and conceal
  240. describe("let the conceal level be", function()
  241. before_each(function()
  242. insert("// No Conceal\n")
  243. insert('"Conceal without a cchar"\n')
  244. insert("+ With cchar\n\n")
  245. command("syn match noConceal '^//.*$'")
  246. command("syn match concealNoCchar '\".\\{-}\"$' conceal")
  247. command("syn match concealWCchar '^+.\\{-}$' conceal cchar=C")
  248. end)
  249. it("0. No concealing.", function()
  250. command("let &conceallevel=0")
  251. screen:expect([[
  252. // No Conceal |
  253. "Conceal without a cchar" |
  254. + With cchar |
  255. |
  256. ^ |
  257. {0:~ }|
  258. {0:~ }|
  259. {0:~ }|
  260. {0:~ }|
  261. |
  262. ]])
  263. end)
  264. it("1. Conceal using cchar or reference listchars.", function()
  265. command("let &conceallevel=1")
  266. screen:expect([[
  267. // No Conceal |
  268. {1: } |
  269. {1:C} |
  270. |
  271. ^ |
  272. {0:~ }|
  273. {0:~ }|
  274. {0:~ }|
  275. {0:~ }|
  276. |
  277. ]])
  278. end)
  279. it("2. Hidden unless cchar is set.", function()
  280. command("let &conceallevel=2")
  281. screen:expect([[
  282. // No Conceal |
  283. |
  284. {1:C} |
  285. |
  286. ^ |
  287. {0:~ }|
  288. {0:~ }|
  289. {0:~ }|
  290. {0:~ }|
  291. |
  292. ]])
  293. end)
  294. it("3. Hide all concealed text.", function()
  295. command("let &conceallevel=3")
  296. screen:expect([[
  297. // No Conceal |
  298. |
  299. |
  300. |
  301. ^ |
  302. {0:~ }|
  303. {0:~ }|
  304. {0:~ }|
  305. {0:~ }|
  306. |
  307. ]])
  308. end)
  309. end) -- conceallevel
  310. describe("cursor movement", function()
  311. before_each(function()
  312. command("syn keyword concealy barf conceal cchar=b")
  313. command("set cole=2")
  314. feed('5Ofoo barf bar barf eggs<esc>')
  315. screen:expect([[
  316. foo {1:b} bar {1:b} eggs |
  317. foo {1:b} bar {1:b} eggs |
  318. foo {1:b} bar {1:b} eggs |
  319. foo {1:b} bar {1:b} eggs |
  320. foo barf bar barf egg^s |
  321. |
  322. {0:~ }|
  323. {0:~ }|
  324. {0:~ }|
  325. |
  326. ]])
  327. end)
  328. it('between windows', function()
  329. feed('k')
  330. command("split")
  331. screen:expect([[
  332. foo {1:b} bar {1:b} eggs |
  333. foo barf bar barf egg^s |
  334. foo {1:b} bar {1:b} eggs |
  335. |
  336. {2:[No Name] [+] }|
  337. foo {1:b} bar {1:b} eggs |
  338. foo {1:b} bar {1:b} eggs |
  339. foo {1:b} bar {1:b} eggs |
  340. {3:[No Name] [+] }|
  341. |
  342. ]])
  343. feed('<c-w>w')
  344. screen:expect([[
  345. foo {1:b} bar {1:b} eggs |
  346. foo {1:b} bar {1:b} eggs |
  347. foo {1:b} bar {1:b} eggs |
  348. |
  349. {3:[No Name] [+] }|
  350. foo {1:b} bar {1:b} eggs |
  351. foo barf bar barf egg^s |
  352. foo {1:b} bar {1:b} eggs |
  353. {2:[No Name] [+] }|
  354. |
  355. ]])
  356. end)
  357. it('in insert mode', function()
  358. feed('i')
  359. screen:expect([[
  360. foo {1:b} bar {1:b} eggs |
  361. foo {1:b} bar {1:b} eggs |
  362. foo {1:b} bar {1:b} eggs |
  363. foo {1:b} bar {1:b} eggs |
  364. foo barf bar barf egg^s |
  365. |
  366. {0:~ }|
  367. {0:~ }|
  368. {0:~ }|
  369. {4:-- INSERT --} |
  370. ]])
  371. feed('<up>')
  372. screen:expect([[
  373. foo {1:b} bar {1:b} eggs |
  374. foo {1:b} bar {1:b} eggs |
  375. foo {1:b} bar {1:b} eggs |
  376. foo barf bar barf egg^s |
  377. foo {1:b} bar {1:b} eggs |
  378. |
  379. {0:~ }|
  380. {0:~ }|
  381. {0:~ }|
  382. {4:-- INSERT --} |
  383. ]])
  384. end)
  385. it('between modes cocu=iv', function()
  386. command('set cocu=iv')
  387. feed('gg')
  388. screen:expect([[
  389. ^foo barf bar barf eggs |
  390. foo {1:b} bar {1:b} eggs |
  391. foo {1:b} bar {1:b} eggs |
  392. foo {1:b} bar {1:b} eggs |
  393. foo {1:b} bar {1:b} eggs |
  394. |
  395. {0:~ }|
  396. {0:~ }|
  397. {0:~ }|
  398. |
  399. ]])
  400. feed('i')
  401. screen:expect([[
  402. ^foo {1:b} bar {1:b} eggs |
  403. foo {1:b} bar {1:b} eggs |
  404. foo {1:b} bar {1:b} eggs |
  405. foo {1:b} bar {1:b} eggs |
  406. foo {1:b} bar {1:b} eggs |
  407. |
  408. {0:~ }|
  409. {0:~ }|
  410. {0:~ }|
  411. {4:-- INSERT --} |
  412. ]])
  413. feed('<esc>')
  414. screen:expect([[
  415. ^foo barf bar barf eggs |
  416. foo {1:b} bar {1:b} eggs |
  417. foo {1:b} bar {1:b} eggs |
  418. foo {1:b} bar {1:b} eggs |
  419. foo {1:b} bar {1:b} eggs |
  420. |
  421. {0:~ }|
  422. {0:~ }|
  423. {0:~ }|
  424. |
  425. ]])
  426. feed('v')
  427. screen:expect([[
  428. ^foo {1:b} bar {1:b} eggs |
  429. foo {1:b} bar {1:b} eggs |
  430. foo {1:b} bar {1:b} eggs |
  431. foo {1:b} bar {1:b} eggs |
  432. foo {1:b} bar {1:b} eggs |
  433. |
  434. {0:~ }|
  435. {0:~ }|
  436. {0:~ }|
  437. {4:-- VISUAL --} |
  438. ]])
  439. feed('<esc>')
  440. screen:expect([[
  441. ^foo barf bar barf eggs |
  442. foo {1:b} bar {1:b} eggs |
  443. foo {1:b} bar {1:b} eggs |
  444. foo {1:b} bar {1:b} eggs |
  445. foo {1:b} bar {1:b} eggs |
  446. |
  447. {0:~ }|
  448. {0:~ }|
  449. {0:~ }|
  450. |
  451. ]])
  452. end)
  453. it('between modes cocu=n', function()
  454. command('set cocu=n')
  455. feed('gg')
  456. screen:expect([[
  457. ^foo {1:b} bar {1:b} eggs |
  458. foo {1:b} bar {1:b} eggs |
  459. foo {1:b} bar {1:b} eggs |
  460. foo {1:b} bar {1:b} eggs |
  461. foo {1:b} bar {1:b} eggs |
  462. |
  463. {0:~ }|
  464. {0:~ }|
  465. {0:~ }|
  466. |
  467. ]])
  468. feed('i')
  469. screen:expect([[
  470. ^foo barf bar barf eggs |
  471. foo {1:b} bar {1:b} eggs |
  472. foo {1:b} bar {1:b} eggs |
  473. foo {1:b} bar {1:b} eggs |
  474. foo {1:b} bar {1:b} eggs |
  475. |
  476. {0:~ }|
  477. {0:~ }|
  478. {0:~ }|
  479. {4:-- INSERT --} |
  480. ]])
  481. feed('<esc>')
  482. screen:expect([[
  483. ^foo {1:b} bar {1:b} eggs |
  484. foo {1:b} bar {1:b} eggs |
  485. foo {1:b} bar {1:b} eggs |
  486. foo {1:b} bar {1:b} eggs |
  487. foo {1:b} bar {1:b} eggs |
  488. |
  489. {0:~ }|
  490. {0:~ }|
  491. {0:~ }|
  492. |
  493. ]])
  494. feed('v')
  495. screen:expect([[
  496. ^foo barf bar barf eggs |
  497. foo {1:b} bar {1:b} eggs |
  498. foo {1:b} bar {1:b} eggs |
  499. foo {1:b} bar {1:b} eggs |
  500. foo {1:b} bar {1:b} eggs |
  501. |
  502. {0:~ }|
  503. {0:~ }|
  504. {0:~ }|
  505. {4:-- VISUAL --} |
  506. ]])
  507. feed('<esc>')
  508. screen:expect([[
  509. ^foo {1:b} bar {1:b} eggs |
  510. foo {1:b} bar {1:b} eggs |
  511. foo {1:b} bar {1:b} eggs |
  512. foo {1:b} bar {1:b} eggs |
  513. foo {1:b} bar {1:b} eggs |
  514. |
  515. {0:~ }|
  516. {0:~ }|
  517. {0:~ }|
  518. |
  519. ]])
  520. end)
  521. it('and open line', function()
  522. feed('o')
  523. screen:expect([[
  524. foo {1:b} bar {1:b} eggs |
  525. foo {1:b} bar {1:b} eggs |
  526. foo {1:b} bar {1:b} eggs |
  527. foo {1:b} bar {1:b} eggs |
  528. foo {1:b} bar {1:b} eggs |
  529. ^ |
  530. |
  531. {0:~ }|
  532. {0:~ }|
  533. {4:-- INSERT --} |
  534. ]])
  535. end)
  536. it('and open line cocu=i', function()
  537. command('set cocu=i')
  538. feed('o')
  539. screen:expect([[
  540. foo {1:b} bar {1:b} eggs |
  541. foo {1:b} bar {1:b} eggs |
  542. foo {1:b} bar {1:b} eggs |
  543. foo {1:b} bar {1:b} eggs |
  544. foo {1:b} bar {1:b} eggs |
  545. ^ |
  546. |
  547. {0:~ }|
  548. {0:~ }|
  549. {4:-- INSERT --} |
  550. ]])
  551. end)
  552. describe('with incsearch', function()
  553. before_each(function()
  554. command('set incsearch hlsearch')
  555. feed('2GA x<esc>3GA xy<esc>gg')
  556. screen:expect([[
  557. ^foo barf bar barf eggs |
  558. foo {1:b} bar {1:b} eggs x |
  559. foo {1:b} bar {1:b} eggs xy |
  560. foo {1:b} bar {1:b} eggs |
  561. foo {1:b} bar {1:b} eggs |
  562. |
  563. {0:~ }|
  564. {0:~ }|
  565. {0:~ }|
  566. |
  567. ]])
  568. end)
  569. it('cocu=', function()
  570. feed('/')
  571. screen:expect([[
  572. foo barf bar barf eggs |
  573. foo {1:b} bar {1:b} eggs x |
  574. foo {1:b} bar {1:b} eggs xy |
  575. foo {1:b} bar {1:b} eggs |
  576. foo {1:b} bar {1:b} eggs |
  577. |
  578. {0:~ }|
  579. {0:~ }|
  580. {0:~ }|
  581. /^ |
  582. ]])
  583. feed('x')
  584. screen:expect([[
  585. foo {1:b} bar {1:b} eggs |
  586. foo barf bar barf eggs {3:x} |
  587. foo {1:b} bar {1:b} eggs {5:x}y |
  588. foo {1:b} bar {1:b} eggs |
  589. foo {1:b} bar {1:b} eggs |
  590. |
  591. {0:~ }|
  592. {0:~ }|
  593. {0:~ }|
  594. /x^ |
  595. ]])
  596. feed('y')
  597. screen:expect([[
  598. foo {1:b} bar {1:b} eggs |
  599. foo {1:b} bar {1:b} eggs x |
  600. foo barf bar barf eggs {3:xy} |
  601. foo {1:b} bar {1:b} eggs |
  602. foo {1:b} bar {1:b} eggs |
  603. |
  604. {0:~ }|
  605. {0:~ }|
  606. {0:~ }|
  607. /xy^ |
  608. ]])
  609. feed('<c-w>')
  610. screen:expect([[
  611. foo barf bar barf eggs |
  612. foo {1:b} bar {1:b} eggs x |
  613. foo {1:b} bar {1:b} eggs xy |
  614. foo {1:b} bar {1:b} eggs |
  615. foo {1:b} bar {1:b} eggs |
  616. |
  617. {0:~ }|
  618. {0:~ }|
  619. {0:~ }|
  620. /^ |
  621. ]])
  622. end)
  623. it('cocu=c', function()
  624. command('set cocu=c')
  625. feed('/')
  626. -- NB: we don't do this redraw. Probably best to still skip it,
  627. -- to avoid annoying distraction from the cmdline
  628. screen:expect([[
  629. foo barf bar barf eggs |
  630. foo {1:b} bar {1:b} eggs x |
  631. foo {1:b} bar {1:b} eggs xy |
  632. foo {1:b} bar {1:b} eggs |
  633. foo {1:b} bar {1:b} eggs |
  634. |
  635. {0:~ }|
  636. {0:~ }|
  637. {0:~ }|
  638. /^ |
  639. ]])
  640. feed('x')
  641. screen:expect([[
  642. foo {1:b} bar {1:b} eggs |
  643. foo {1:b} bar {1:b} eggs {3:x} |
  644. foo {1:b} bar {1:b} eggs {5:x}y |
  645. foo {1:b} bar {1:b} eggs |
  646. foo {1:b} bar {1:b} eggs |
  647. |
  648. {0:~ }|
  649. {0:~ }|
  650. {0:~ }|
  651. /x^ |
  652. ]])
  653. feed('y')
  654. screen:expect([[
  655. foo {1:b} bar {1:b} eggs |
  656. foo {1:b} bar {1:b} eggs x |
  657. foo {1:b} bar {1:b} eggs {3:xy} |
  658. foo {1:b} bar {1:b} eggs |
  659. foo {1:b} bar {1:b} eggs |
  660. |
  661. {0:~ }|
  662. {0:~ }|
  663. {0:~ }|
  664. /xy^ |
  665. ]])
  666. feed('<c-w>')
  667. screen:expect([[
  668. foo {1:b} bar {1:b} eggs |
  669. foo {1:b} bar {1:b} eggs x |
  670. foo {1:b} bar {1:b} eggs xy |
  671. foo {1:b} bar {1:b} eggs |
  672. foo {1:b} bar {1:b} eggs |
  673. |
  674. {0:~ }|
  675. {0:~ }|
  676. {0:~ }|
  677. /^ |
  678. ]])
  679. feed('<esc>')
  680. screen:expect([[
  681. ^foo barf bar barf eggs |
  682. foo {1:b} bar {1:b} eggs x |
  683. foo {1:b} bar {1:b} eggs xy |
  684. foo {1:b} bar {1:b} eggs |
  685. foo {1:b} bar {1:b} eggs |
  686. |
  687. {0:~ }|
  688. {0:~ }|
  689. {0:~ }|
  690. |
  691. ]])
  692. end)
  693. it('cocu=n', function()
  694. command('set cocu=n')
  695. screen:expect([[
  696. ^foo {1:b} bar {1:b} eggs |
  697. foo {1:b} bar {1:b} eggs x |
  698. foo {1:b} bar {1:b} eggs xy |
  699. foo {1:b} bar {1:b} eggs |
  700. foo {1:b} bar {1:b} eggs |
  701. |
  702. {0:~ }|
  703. {0:~ }|
  704. {0:~ }|
  705. |
  706. ]])
  707. feed('/')
  708. -- NB: we don't do this redraw. Probably best to still skip it,
  709. -- to avoid annoying distraction from the cmdline
  710. screen:expect([[
  711. foo {1:b} bar {1:b} eggs |
  712. foo {1:b} bar {1:b} eggs x |
  713. foo {1:b} bar {1:b} eggs xy |
  714. foo {1:b} bar {1:b} eggs |
  715. foo {1:b} bar {1:b} eggs |
  716. |
  717. {0:~ }|
  718. {0:~ }|
  719. {0:~ }|
  720. /^ |
  721. ]])
  722. feed('x')
  723. screen:expect([[
  724. foo {1:b} bar {1:b} eggs |
  725. foo barf bar barf eggs {3:x} |
  726. foo {1:b} bar {1:b} eggs {5:x}y |
  727. foo {1:b} bar {1:b} eggs |
  728. foo {1:b} bar {1:b} eggs |
  729. |
  730. {0:~ }|
  731. {0:~ }|
  732. {0:~ }|
  733. /x^ |
  734. ]])
  735. feed('<c-w>')
  736. screen:expect([[
  737. foo barf bar barf eggs |
  738. foo {1:b} bar {1:b} eggs x |
  739. foo {1:b} bar {1:b} eggs xy |
  740. foo {1:b} bar {1:b} eggs |
  741. foo {1:b} bar {1:b} eggs |
  742. |
  743. {0:~ }|
  744. {0:~ }|
  745. {0:~ }|
  746. /^ |
  747. ]])
  748. feed('<esc>')
  749. screen:expect([[
  750. ^foo {1:b} bar {1:b} eggs |
  751. foo {1:b} bar {1:b} eggs x |
  752. foo {1:b} bar {1:b} eggs xy |
  753. foo {1:b} bar {1:b} eggs |
  754. foo {1:b} bar {1:b} eggs |
  755. |
  756. {0:~ }|
  757. {0:~ }|
  758. {0:~ }|
  759. |
  760. ]])
  761. end)
  762. end)
  763. it('redraws properly with concealcursor in visual mode', function()
  764. command('set concealcursor=v conceallevel=2')
  765. feed('10Ofoo barf bar barf eggs<esc>')
  766. feed(':3<cr>o a<Esc>ggV')
  767. screen:expect{grid=[[
  768. ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} |
  769. foo {1:b} bar {1:b} eggs |
  770. foo {1:b} bar {1:b} eggs |
  771. a |
  772. foo {1:b} bar {1:b} eggs |
  773. foo {1:b} bar {1:b} eggs |
  774. foo {1:b} bar {1:b} eggs |
  775. foo {1:b} bar {1:b} eggs |
  776. foo {1:b} bar {1:b} eggs |
  777. {4:-- VISUAL LINE --} |
  778. ]]}
  779. feed(string.rep('j', 15))
  780. screen:expect{grid=[[
  781. {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |
  782. {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |
  783. {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |
  784. {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |
  785. {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |
  786. {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |
  787. {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |
  788. {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |
  789. ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} |
  790. {4:-- VISUAL LINE --} |
  791. ]]}
  792. feed(string.rep('k', 15))
  793. screen:expect{grid=[[
  794. ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} |
  795. foo {1:b} bar {1:b} eggs |
  796. foo {1:b} bar {1:b} eggs |
  797. a |
  798. foo {1:b} bar {1:b} eggs |
  799. foo {1:b} bar {1:b} eggs |
  800. foo {1:b} bar {1:b} eggs |
  801. foo {1:b} bar {1:b} eggs |
  802. foo {1:b} bar {1:b} eggs |
  803. {4:-- VISUAL LINE --} |
  804. ]]}
  805. end)
  806. end)
  807. it('redraws not too much with conceallevel=1', function()
  808. command('set conceallevel=1')
  809. command('set redrawdebug+=nodelta')
  810. insert([[
  811. aaa
  812. bbb
  813. ccc
  814. ]])
  815. screen:expect{grid=[[
  816. aaa |
  817. bbb |
  818. ccc |
  819. ^ |
  820. {0:~ }|
  821. {0:~ }|
  822. {0:~ }|
  823. {0:~ }|
  824. {0:~ }|
  825. |
  826. ]]}
  827. -- XXX: hack to get notifications, and check only a single line is
  828. -- updated. Could use next_msg() also.
  829. local orig_handle_grid_line = screen._handle_grid_line
  830. local grid_lines = {}
  831. function screen._handle_grid_line(self, grid, row, col, items)
  832. table.insert(grid_lines, {row, col, items})
  833. orig_handle_grid_line(self, grid, row, col, items)
  834. end
  835. feed('k')
  836. screen:expect{grid=[[
  837. aaa |
  838. bbb |
  839. ^ccc |
  840. |
  841. {0:~ }|
  842. {0:~ }|
  843. {0:~ }|
  844. {0:~ }|
  845. {0:~ }|
  846. |
  847. ]]}
  848. eq(grid_lines, {{2, 0, {{'c', 0, 3}}}})
  849. end)
  850. end)