conceal_spec.lua 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local Screen = require('test.functional.ui.screen')
  4. local clear = n.clear
  5. local command = n.command
  6. local exec = n.exec
  7. local feed = n.feed
  8. local api = n.api
  9. local expect_pos = function(row, col)
  10. return t.eq({ row, col }, n.eval('[screenrow(), screencol()]'))
  11. end
  12. describe('Conceal', function()
  13. before_each(function()
  14. clear()
  15. command('set nohlsearch')
  16. end)
  17. -- oldtest: Test_conceal_two_windows()
  18. it('works', function()
  19. local screen = Screen.new(75, 12)
  20. exec([[
  21. let lines = ["one one one one one", "two |hidden| here", "three |hidden| three"]
  22. call setline(1, lines)
  23. syntax match test /|hidden|/ conceal
  24. set conceallevel=2
  25. set concealcursor=
  26. exe "normal /here\r"
  27. new
  28. call setline(1, lines)
  29. call setline(4, "Second window")
  30. syntax match test /|hidden|/ conceal
  31. set conceallevel=2
  32. set concealcursor=nc
  33. exe "normal /here\r"
  34. ]])
  35. -- Check that cursor line is concealed
  36. screen:expect([[
  37. one one one one one |
  38. two ^here |
  39. three three |
  40. Second window |
  41. {1:~ }|
  42. {3:[No Name] [+] }|
  43. one one one one one |
  44. two here |
  45. three three |
  46. {1:~ }|
  47. {2:[No Name] [+] }|
  48. /here |
  49. ]])
  50. -- Check that with concealed text vertical cursor movement is correct.
  51. feed('k')
  52. screen:expect([[
  53. one one one o^ne one |
  54. two here |
  55. three three |
  56. Second window |
  57. {1:~ }|
  58. {3:[No Name] [+] }|
  59. one one one one one |
  60. two here |
  61. three three |
  62. {1:~ }|
  63. {2:[No Name] [+] }|
  64. /here |
  65. ]])
  66. -- Check that with cursor line is not concealed
  67. feed('j')
  68. command('set concealcursor=')
  69. screen:expect([[
  70. one one one one one |
  71. two |hidden| ^here |
  72. three three |
  73. Second window |
  74. {1:~ }|
  75. {3:[No Name] [+] }|
  76. one one one one one |
  77. two here |
  78. three three |
  79. {1:~ }|
  80. {2:[No Name] [+] }|
  81. /here |
  82. ]])
  83. -- Check that with cursor line is not concealed when moving cursor down
  84. feed('j')
  85. screen:expect([[
  86. one one one one one |
  87. two here |
  88. three |hidden^| three |
  89. Second window |
  90. {1:~ }|
  91. {3:[No Name] [+] }|
  92. one one one one one |
  93. two here |
  94. three three |
  95. {1:~ }|
  96. {2:[No Name] [+] }|
  97. /here |
  98. ]])
  99. -- Check that with cursor line is not concealed when switching windows
  100. feed('<C-W><C-W>')
  101. screen:expect([[
  102. one one one one one |
  103. two here |
  104. three three |
  105. Second window |
  106. {1:~ }|
  107. {2:[No Name] [+] }|
  108. one one one one one |
  109. two |hidden| ^here |
  110. three three |
  111. {1:~ }|
  112. {3:[No Name] [+] }|
  113. /here |
  114. ]])
  115. -- Check that with cursor line is only concealed in Normal mode
  116. command('set concealcursor=n')
  117. screen:expect([[
  118. one one one one one |
  119. two here |
  120. three three |
  121. Second window |
  122. {1:~ }|
  123. {2:[No Name] [+] }|
  124. one one one one one |
  125. two ^here |
  126. three three |
  127. {1:~ }|
  128. {3:[No Name] [+] }|
  129. /here |
  130. ]])
  131. feed('a')
  132. screen:expect([[
  133. one one one one one |
  134. two here |
  135. three three |
  136. Second window |
  137. {1:~ }|
  138. {2:[No Name] [+] }|
  139. one one one one one |
  140. two |hidden| h^ere |
  141. three three |
  142. {1:~ }|
  143. {3:[No Name] [+] }|
  144. {5:-- INSERT --} |
  145. ]])
  146. feed('<Esc>/e')
  147. screen:expect([[
  148. one one one one one |
  149. two here |
  150. three three |
  151. Second window |
  152. {1:~ }|
  153. {2:[No Name] [+] }|
  154. one one one one one |
  155. two |hidden| h{2:e}re |
  156. three three |
  157. {1:~ }|
  158. {3:[No Name] [+] }|
  159. /e^ |
  160. ]])
  161. feed('<Esc>v')
  162. screen:expect([[
  163. one one one one one |
  164. two here |
  165. three three |
  166. Second window |
  167. {1:~ }|
  168. {2:[No Name] [+] }|
  169. one one one one one |
  170. two |hidden| ^here |
  171. three three |
  172. {1:~ }|
  173. {3:[No Name] [+] }|
  174. {5:-- VISUAL --} |
  175. ]])
  176. feed('<Esc>')
  177. -- Check that with cursor line is only concealed in Insert mode
  178. command('set concealcursor=i')
  179. screen:expect([[
  180. one one one one one |
  181. two here |
  182. three three |
  183. Second window |
  184. {1:~ }|
  185. {2:[No Name] [+] }|
  186. one one one one one |
  187. two |hidden| ^here |
  188. three three |
  189. {1:~ }|
  190. {3:[No Name] [+] }|
  191. |
  192. ]])
  193. feed('a')
  194. screen:expect([[
  195. one one one one one |
  196. two here |
  197. three three |
  198. Second window |
  199. {1:~ }|
  200. {2:[No Name] [+] }|
  201. one one one one one |
  202. two h^ere |
  203. three three |
  204. {1:~ }|
  205. {3:[No Name] [+] }|
  206. {5:-- INSERT --} |
  207. ]])
  208. feed('<Esc>/e')
  209. screen:expect([[
  210. one one one one one |
  211. two here |
  212. three three |
  213. Second window |
  214. {1:~ }|
  215. {2:[No Name] [+] }|
  216. one one one one one |
  217. two |hidden| h{2:e}re |
  218. three three |
  219. {1:~ }|
  220. {3:[No Name] [+] }|
  221. /e^ |
  222. ]])
  223. feed('<Esc>v')
  224. screen:expect([[
  225. one one one one one |
  226. two here |
  227. three three |
  228. Second window |
  229. {1:~ }|
  230. {2:[No Name] [+] }|
  231. one one one one one |
  232. two |hidden| ^here |
  233. three three |
  234. {1:~ }|
  235. {3:[No Name] [+] }|
  236. {5:-- VISUAL --} |
  237. ]])
  238. feed('<Esc>')
  239. -- Check that with cursor line is only concealed in Visual mode
  240. command('set concealcursor=v')
  241. screen:expect([[
  242. one one one one one |
  243. two here |
  244. three three |
  245. Second window |
  246. {1:~ }|
  247. {2:[No Name] [+] }|
  248. one one one one one |
  249. two |hidden| ^here |
  250. three three |
  251. {1:~ }|
  252. {3:[No Name] [+] }|
  253. |
  254. ]])
  255. feed('a')
  256. screen:expect([[
  257. one one one one one |
  258. two here |
  259. three three |
  260. Second window |
  261. {1:~ }|
  262. {2:[No Name] [+] }|
  263. one one one one one |
  264. two |hidden| h^ere |
  265. three three |
  266. {1:~ }|
  267. {3:[No Name] [+] }|
  268. {5:-- INSERT --} |
  269. ]])
  270. feed('<Esc>/e')
  271. screen:expect([[
  272. one one one one one |
  273. two here |
  274. three three |
  275. Second window |
  276. {1:~ }|
  277. {2:[No Name] [+] }|
  278. one one one one one |
  279. two |hidden| h{2:e}re |
  280. three three |
  281. {1:~ }|
  282. {3:[No Name] [+] }|
  283. /e^ |
  284. ]])
  285. feed('<Esc>v')
  286. screen:expect([[
  287. one one one one one |
  288. two here |
  289. three three |
  290. Second window |
  291. {1:~ }|
  292. {2:[No Name] [+] }|
  293. one one one one one |
  294. two ^here |
  295. three three |
  296. {1:~ }|
  297. {3:[No Name] [+] }|
  298. {5:-- VISUAL --} |
  299. ]])
  300. feed('<Esc>')
  301. -- Check moving the cursor while in insert mode.
  302. command('set concealcursor=')
  303. feed('a')
  304. screen:expect([[
  305. one one one one one |
  306. two here |
  307. three three |
  308. Second window |
  309. {1:~ }|
  310. {2:[No Name] [+] }|
  311. one one one one one |
  312. two |hidden| h^ere |
  313. three three |
  314. {1:~ }|
  315. {3:[No Name] [+] }|
  316. {5:-- INSERT --} |
  317. ]])
  318. feed('<Down>')
  319. screen:expect([[
  320. one one one one one |
  321. two here |
  322. three three |
  323. Second window |
  324. {1:~ }|
  325. {2:[No Name] [+] }|
  326. one one one one one |
  327. two here |
  328. three |hidden|^ three |
  329. {1:~ }|
  330. {3:[No Name] [+] }|
  331. {5:-- INSERT --} |
  332. ]])
  333. feed('<Esc>')
  334. -- Check the "o" command
  335. screen:expect([[
  336. one one one one one |
  337. two here |
  338. three three |
  339. Second window |
  340. {1:~ }|
  341. {2:[No Name] [+] }|
  342. one one one one one |
  343. two here |
  344. three |hidden^| three |
  345. {1:~ }|
  346. {3:[No Name] [+] }|
  347. |
  348. ]])
  349. feed('o')
  350. screen:expect([[
  351. one one one one one |
  352. two here |
  353. three three |
  354. Second window |
  355. {1:~ }|
  356. {2:[No Name] [+] }|
  357. one one one one one |
  358. two here |
  359. three three |
  360. ^ |
  361. {3:[No Name] [+] }|
  362. {5:-- INSERT --} |
  363. ]])
  364. feed('<Esc>')
  365. end)
  366. -- oldtest: Test_conceal_with_cursorcolumn()
  367. it('CursorColumn and ColorColumn on wrapped line', function()
  368. local screen = Screen.new(40, 10)
  369. screen:add_extra_attr_ids {
  370. [100] = { background = Screen.colors.LightRed },
  371. }
  372. -- Check that cursorcolumn and colorcolumn don't get broken in presence of
  373. -- wrapped lines containing concealed text
  374. -- luacheck: push ignore 613 (trailing whitespace in a string)
  375. exec([[
  376. let lines = ["one one one |hidden| one one one one one one one one",
  377. \ "two two two two |hidden| here two two",
  378. \ "three |hidden| three three three three three three three three"]
  379. call setline(1, lines)
  380. set wrap linebreak
  381. set showbreak=\ >>>\
  382. syntax match test /|hidden|/ conceal
  383. set conceallevel=2
  384. set concealcursor=
  385. exe "normal /here\r"
  386. set cursorcolumn
  387. set colorcolumn=50
  388. ]])
  389. -- luacheck: pop
  390. screen:expect([[
  391. one one one one one one {21:o}ne |
  392. {1: >>> }one {100:o}ne one one |
  393. two two two two |hidden| ^here two two |
  394. three three three three {21:t}hree |
  395. {1: >>> }thre{100:e} three three three |
  396. {1:~ }|*4
  397. /here |
  398. ]])
  399. -- move cursor to the end of line (the cursor jumps to the next screen line)
  400. feed('$')
  401. screen:expect([[
  402. one one one one one one one |
  403. {1: >>> }one {100:o}ne one one |
  404. two two two two |hidden| here two tw^o |
  405. three three three three three |
  406. {1: >>> }thre{100:e} three three three |
  407. {1:~ }|*4
  408. /here |
  409. ]])
  410. end)
  411. -- oldtest: Test_conceal_wrapped_cursorline_wincolor()
  412. it('CursorLine highlight on wrapped lines', function()
  413. local screen = Screen.new(40, 4)
  414. screen:add_extra_attr_ids {
  415. [100] = { background = Screen.colors.WebGreen },
  416. }
  417. exec([[
  418. call setline(1, 'one one one |hidden| one one one one one one one one')
  419. syntax match test /|hidden|/ conceal
  420. set conceallevel=2 concealcursor=n cursorline
  421. normal! g$
  422. hi! CursorLine guibg=Green
  423. ]])
  424. screen:expect([[
  425. {100:one one one one one one one on^e }|
  426. {100: one one one }|
  427. {1:~ }|
  428. |
  429. ]])
  430. command('hi! CursorLine guibg=NONE guifg=Red')
  431. screen:expect([[
  432. {19:one one one one one one one on^e }|
  433. {19: one one one }|
  434. {1:~ }|
  435. |
  436. ]])
  437. end)
  438. -- oldtest: Test_conceal_wrapped_cursorline_wincolor_rightleft()
  439. it('CursorLine highlight on wrapped lines with rightleft', function()
  440. local screen = Screen.new(40, 4)
  441. screen:add_extra_attr_ids {
  442. [100] = { background = Screen.colors.WebGreen },
  443. }
  444. exec([[
  445. call setline(1, 'one one one |hidden| one one one one one one one one')
  446. syntax match test /|hidden|/ conceal
  447. set conceallevel=2 concealcursor=n cursorline rightleft
  448. normal! g$
  449. hi! CursorLine guibg=Green
  450. ]])
  451. screen:expect([[
  452. {100: ^eno eno eno eno eno eno eno eno}|
  453. {100: eno eno eno }|
  454. {1: ~}|
  455. |
  456. ]])
  457. command('hi! CursorLine guibg=NONE guifg=Red')
  458. screen:expect([[
  459. {19: ^eno eno eno eno eno eno eno eno}|
  460. {19: eno eno eno }|
  461. {1: ~}|
  462. |
  463. ]])
  464. end)
  465. -- oldtest: Test_conceal_resize_term()
  466. it('resize editor', function()
  467. local screen = Screen.new(75, 6)
  468. exec([[
  469. call setline(1, '`one` `two` `three` `four` `five`, the backticks should be concealed')
  470. setl cocu=n cole=3
  471. syn region CommentCodeSpan matchgroup=Comment start=/`/ end=/`/ concealends
  472. normal fb
  473. ]])
  474. screen:expect([[
  475. one two three four five, the ^backticks should be concealed |
  476. {1:~ }|*4
  477. |
  478. ]])
  479. screen:try_resize(75, 7)
  480. screen:expect([[
  481. one two three four five, the ^backticks should be concealed |
  482. {1:~ }|*5
  483. |
  484. ]])
  485. end)
  486. -- oldtest: Test_conceal_linebreak()
  487. it('with linebreak', function()
  488. local screen = Screen.new(75, 8)
  489. exec([[
  490. let &wrap = v:true
  491. let &conceallevel = 2
  492. let &concealcursor = 'nc'
  493. let &linebreak = v:true
  494. let &showbreak = '+ '
  495. let line = 'a`a`a`a`'
  496. \ .. 'a'->repeat(&columns - 15)
  497. \ .. ' b`b`'
  498. \ .. 'b'->repeat(&columns - 10)
  499. \ .. ' cccccc'
  500. eval ['x'->repeat(&columns), '', line]->setline(1)
  501. syntax region CodeSpan matchgroup=Delimiter start=/\z(`\+\)/ end=/\z1/ concealends
  502. ]])
  503. screen:expect([[
  504. ^xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
  505. |
  506. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
  507. {1:+ }bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb |
  508. {1:+ }cccccc |
  509. {1:~ }|*2
  510. |
  511. ]])
  512. end)
  513. -- Tests for correct display (cursor column position) with +conceal and tabulators.
  514. -- oldtest: Test_conceal_cursor_pos()
  515. it('cursor and column position with conceal and tabulators', function()
  516. exec([[
  517. let l = ['start:', '.concealed. text', "|concealed|\ttext"]
  518. let l += ['', "\t.concealed.\ttext", "\t|concealed|\ttext", '']
  519. let l += [".a.\t.b.\t.c.\t.d.", "|a|\t|b|\t|c|\t|d|"]
  520. call append(0, l)
  521. call cursor(1, 1)
  522. " Conceal settings.
  523. set conceallevel=2
  524. set concealcursor=nc
  525. syntax match test /|/ conceal
  526. ]])
  527. feed('ztj')
  528. expect_pos(2, 1)
  529. -- We should end up in the same column when running these commands on the
  530. -- two lines.
  531. feed('ft')
  532. expect_pos(2, 17)
  533. feed('$')
  534. expect_pos(2, 20)
  535. feed('0j')
  536. expect_pos(3, 1)
  537. feed('ft')
  538. expect_pos(3, 17)
  539. feed('$')
  540. expect_pos(3, 20)
  541. feed('j0j')
  542. expect_pos(5, 8)
  543. -- Same for next test block.
  544. feed('ft')
  545. expect_pos(5, 25)
  546. feed('$')
  547. expect_pos(5, 28)
  548. feed('0j')
  549. expect_pos(6, 8)
  550. feed('ft')
  551. expect_pos(6, 25)
  552. feed('$')
  553. expect_pos(6, 28)
  554. feed('0j0j')
  555. expect_pos(8, 1)
  556. -- And check W with multiple tabs and conceals in a line.
  557. feed('W')
  558. expect_pos(8, 9)
  559. feed('W')
  560. expect_pos(8, 17)
  561. feed('W')
  562. expect_pos(8, 25)
  563. feed('$')
  564. expect_pos(8, 27)
  565. feed('0j')
  566. expect_pos(9, 1)
  567. feed('W')
  568. expect_pos(9, 9)
  569. feed('W')
  570. expect_pos(9, 17)
  571. feed('W')
  572. expect_pos(9, 25)
  573. feed('$')
  574. expect_pos(9, 26)
  575. command('set lbr')
  576. feed('$')
  577. expect_pos(9, 26)
  578. command('set list listchars=tab:>-')
  579. feed('0')
  580. expect_pos(9, 1)
  581. feed('W')
  582. expect_pos(9, 9)
  583. feed('W')
  584. expect_pos(9, 17)
  585. feed('W')
  586. expect_pos(9, 25)
  587. feed('$')
  588. expect_pos(9, 26)
  589. end)
  590. local function test_conceal_virtualedit_after_eol(wrap)
  591. local screen = Screen.new(60, 3)
  592. api.nvim_set_option_value('wrap', wrap, {})
  593. exec([[
  594. call setline(1, 'abcdefgh|hidden|ijklmnpop')
  595. syntax match test /|hidden|/ conceal
  596. set conceallevel=2 concealcursor=n virtualedit=all
  597. normal! $
  598. ]])
  599. screen:expect([[
  600. abcdefghijklmnpo^p |
  601. {1:~ }|
  602. |
  603. ]])
  604. feed('l')
  605. screen:expect([[
  606. abcdefghijklmnpop^ |
  607. {1:~ }|
  608. |
  609. ]])
  610. feed('l')
  611. screen:expect([[
  612. abcdefghijklmnpop ^ |
  613. {1:~ }|
  614. |
  615. ]])
  616. feed('l')
  617. screen:expect([[
  618. abcdefghijklmnpop ^ |
  619. {1:~ }|
  620. |
  621. ]])
  622. feed('rr')
  623. screen:expect([[
  624. abcdefghijklmnpop ^r |
  625. {1:~ }|
  626. |
  627. ]])
  628. end
  629. -- oldtest: Test_conceal_virtualedit_after_eol()
  630. describe('cursor drawn at correct column with virtualedit', function()
  631. it('with wrapping', function()
  632. test_conceal_virtualedit_after_eol(true)
  633. end)
  634. it('without wrapping', function()
  635. test_conceal_virtualedit_after_eol(false)
  636. end)
  637. end)
  638. local function test_conceal_virtualedit_after_eol_rightleft(wrap)
  639. local screen = Screen.new(60, 3)
  640. api.nvim_set_option_value('wrap', wrap, {})
  641. exec([[
  642. call setline(1, 'abcdefgh|hidden|ijklmnpop')
  643. syntax match test /|hidden|/ conceal
  644. set conceallevel=2 concealcursor=n virtualedit=all rightleft
  645. normal! $
  646. ]])
  647. screen:expect([[
  648. ^popnmlkjihgfedcba|
  649. {1: ~}|
  650. |
  651. ]])
  652. feed('h')
  653. screen:expect([[
  654. ^ popnmlkjihgfedcba|
  655. {1: ~}|
  656. |
  657. ]])
  658. feed('h')
  659. screen:expect([[
  660. ^ popnmlkjihgfedcba|
  661. {1: ~}|
  662. |
  663. ]])
  664. feed('h')
  665. screen:expect([[
  666. ^ popnmlkjihgfedcba|
  667. {1: ~}|
  668. |
  669. ]])
  670. feed('rr')
  671. screen:expect([[
  672. ^r popnmlkjihgfedcba|
  673. {1: ~}|
  674. |
  675. ]])
  676. end
  677. -- oldtest: Test_conceal_virtualedit_after_eol_rightleft()
  678. describe('cursor drawn correctly with virtualedit and rightleft', function()
  679. it('with wrapping', function()
  680. test_conceal_virtualedit_after_eol_rightleft(true)
  681. end)
  682. it('without wrapping', function()
  683. test_conceal_virtualedit_after_eol_rightleft(false)
  684. end)
  685. end)
  686. local function test_conceal_double_width(wrap)
  687. local screen = Screen.new(60, 4)
  688. screen:add_extra_attr_ids {
  689. [100] = { background = Screen.colors.LightRed },
  690. }
  691. api.nvim_set_option_value('wrap', wrap, {})
  692. exec([[
  693. call setline(1, ['aaaaa口=口bbbbb口=口ccccc', 'foobar'])
  694. syntax match test /口=口/ conceal cchar=β
  695. set conceallevel=2 concealcursor=n colorcolumn=30
  696. normal! $
  697. ]])
  698. screen:expect([[
  699. aaaaa{14:β}bbbbb{14:β}cccc^c {100: } |
  700. foobar {100: } |
  701. {1:~ }|
  702. |
  703. ]])
  704. feed('gM')
  705. screen:expect([[
  706. aaaaa{14:β}bb^bbb{14:β}ccccc {100: } |
  707. foobar {100: } |
  708. {1:~ }|
  709. |
  710. ]])
  711. command('set conceallevel=3')
  712. screen:expect([[
  713. aaaaabb^bbbccccc {100: } |
  714. foobar {100: } |
  715. {1:~ }|
  716. |
  717. ]])
  718. feed('$')
  719. screen:expect([[
  720. aaaaabbbbbcccc^c {100: } |
  721. foobar {100: } |
  722. {1:~ }|
  723. |
  724. ]])
  725. end
  726. -- oldtest: Test_conceal_double_width()
  727. describe('cursor drawn correctly when double-width chars are concealed', function()
  728. it('with wrapping', function()
  729. test_conceal_double_width(true)
  730. end)
  731. it('without wrapping', function()
  732. test_conceal_double_width(false)
  733. end)
  734. end)
  735. -- oldtest: Test_conceal_double_width_wrap()
  736. it('line wraps correctly when double-width chars are concealed', function()
  737. local screen = Screen.new(20, 4)
  738. screen:add_extra_attr_ids {
  739. [100] = { background = Screen.colors.LightRed },
  740. }
  741. exec([[
  742. call setline(1, 'aaaaaaaaaa口=口bbbbbbbbbb口=口cccccccccc')
  743. syntax match test /口=口/ conceal cchar=β
  744. set conceallevel=2 concealcursor=n
  745. normal! $
  746. ]])
  747. screen:expect([[
  748. aaaaaaaaaa{14:β}bbbbb |
  749. bbbbb{14:β}ccccccccc^c |
  750. {1:~ }|
  751. |
  752. ]])
  753. feed('gM')
  754. screen:expect([[
  755. aaaaaaaaaa{14:β}bbbbb |
  756. ^bbbbb{14:β}cccccccccc |
  757. {1:~ }|
  758. |
  759. ]])
  760. command('set conceallevel=3')
  761. screen:expect([[
  762. aaaaaaaaaabbbbb |
  763. ^bbbbbcccccccccc |
  764. {1:~ }|
  765. |
  766. ]])
  767. feed('$')
  768. screen:expect([[
  769. aaaaaaaaaabbbbb |
  770. bbbbbccccccccc^c |
  771. {1:~ }|
  772. |
  773. ]])
  774. end)
  775. end)