test_conceal.vim (23539B)
1 " Tests for 'conceal'. 2 3 source check.vim 4 CheckFeature conceal 5 6 source screendump.vim 7 source view_util.vim 8 9 func Test_conceal_two_windows() 10 CheckScreendump 11 12 let code =<< trim [CODE] 13 let lines = ["one one one one one", "two |hidden| here", "three |hidden| three"] 14 call setline(1, lines) 15 syntax match test /|hidden|/ conceal 16 set conceallevel=2 17 set concealcursor= 18 exe "normal /here\r" 19 new 20 call setline(1, lines) 21 call setline(4, "Second window") 22 syntax match test /|hidden|/ conceal 23 set conceallevel=2 24 set concealcursor=nc 25 exe "normal /here\r" 26 [CODE] 27 28 call writefile(code, 'XTest_conceal', 'D') 29 " Check that cursor line is concealed 30 let buf = RunVimInTerminal('-S XTest_conceal', {}) 31 call VerifyScreenDump(buf, 'Test_conceal_two_windows_01', {}) 32 33 " Check that with concealed text vertical cursor movement is correct. 34 call term_sendkeys(buf, "k") 35 call VerifyScreenDump(buf, 'Test_conceal_two_windows_02', {}) 36 37 " Check that with cursor line is not concealed 38 call term_sendkeys(buf, "j") 39 call term_sendkeys(buf, ":set concealcursor=\r") 40 call VerifyScreenDump(buf, 'Test_conceal_two_windows_03', {}) 41 42 " Check that with cursor line is not concealed when moving cursor down 43 call term_sendkeys(buf, "j") 44 call VerifyScreenDump(buf, 'Test_conceal_two_windows_04', {}) 45 46 " Check that with cursor line is not concealed when switching windows 47 call term_sendkeys(buf, "\<C-W>\<C-W>") 48 call VerifyScreenDump(buf, 'Test_conceal_two_windows_05', {}) 49 50 " Check that with cursor line is only concealed in Normal mode 51 call term_sendkeys(buf, ":set concealcursor=n\r") 52 call VerifyScreenDump(buf, 'Test_conceal_two_windows_06n', {}) 53 call term_sendkeys(buf, "a") 54 call VerifyScreenDump(buf, 'Test_conceal_two_windows_06i', {}) 55 call term_sendkeys(buf, "\<Esc>/e") 56 call VerifyScreenDump(buf, 'Test_conceal_two_windows_06c', {}) 57 call term_sendkeys(buf, "\<Esc>v") 58 call VerifyScreenDump(buf, 'Test_conceal_two_windows_06v', {}) 59 call term_sendkeys(buf, "\<Esc>") 60 61 " Check that with cursor line is only concealed in Insert mode 62 call term_sendkeys(buf, ":set concealcursor=i\r") 63 call VerifyScreenDump(buf, 'Test_conceal_two_windows_07n', {}) 64 call term_sendkeys(buf, "a") 65 call VerifyScreenDump(buf, 'Test_conceal_two_windows_07i', {}) 66 call term_sendkeys(buf, "\<Esc>/e") 67 call VerifyScreenDump(buf, 'Test_conceal_two_windows_07c', {}) 68 call term_sendkeys(buf, "\<Esc>v") 69 call VerifyScreenDump(buf, 'Test_conceal_two_windows_07v', {}) 70 call term_sendkeys(buf, "\<Esc>") 71 72 " Check that with cursor line is only concealed in Command mode 73 call term_sendkeys(buf, ":set concealcursor=c\r") 74 call VerifyScreenDump(buf, 'Test_conceal_two_windows_08n', {}) 75 call term_sendkeys(buf, "a") 76 call VerifyScreenDump(buf, 'Test_conceal_two_windows_08i', {}) 77 call term_sendkeys(buf, "\<Esc>/e") 78 call VerifyScreenDump(buf, 'Test_conceal_two_windows_08c', {}) 79 call term_sendkeys(buf, "\<Esc>v") 80 call VerifyScreenDump(buf, 'Test_conceal_two_windows_08v', {}) 81 call term_sendkeys(buf, "\<Esc>") 82 83 " Check that with cursor line is only concealed in Visual mode 84 call term_sendkeys(buf, ":set concealcursor=v\r") 85 call VerifyScreenDump(buf, 'Test_conceal_two_windows_09n', {}) 86 call term_sendkeys(buf, "a") 87 call VerifyScreenDump(buf, 'Test_conceal_two_windows_09i', {}) 88 call term_sendkeys(buf, "\<Esc>/e") 89 call VerifyScreenDump(buf, 'Test_conceal_two_windows_09c', {}) 90 call term_sendkeys(buf, "\<Esc>v") 91 call VerifyScreenDump(buf, 'Test_conceal_two_windows_09v', {}) 92 call term_sendkeys(buf, "\<Esc>") 93 94 " Check moving the cursor while in insert mode. 95 call term_sendkeys(buf, ":set concealcursor=\r") 96 call term_sendkeys(buf, "a") 97 call VerifyScreenDump(buf, 'Test_conceal_two_windows_10', {}) 98 call term_sendkeys(buf, "\<Down>") 99 call VerifyScreenDump(buf, 'Test_conceal_two_windows_11', {}) 100 call term_sendkeys(buf, "\<Esc>") 101 102 " Check the "o" command 103 call VerifyScreenDump(buf, 'Test_conceal_two_windows_12', {}) 104 call term_sendkeys(buf, "o") 105 call VerifyScreenDump(buf, 'Test_conceal_two_windows_13', {}) 106 call term_sendkeys(buf, "\<Esc>") 107 108 " clean up 109 call StopVimInTerminal(buf) 110 endfunc 111 112 func Test_conceal_with_cursorline() 113 CheckScreendump 114 115 " Opens a help window, where 'conceal' is set, switches to the other window 116 " where 'cursorline' needs to be updated when the cursor moves. 117 let code =<< trim [CODE] 118 set cursorline 119 normal othis is a test 120 new 121 call setline(1, ["one", "two", "three", "four", "five"]) 122 set ft=help 123 normal M 124 [CODE] 125 126 call writefile(code, 'XTest_conceal_cul', 'D') 127 let buf = RunVimInTerminal('-S XTest_conceal_cul', {}) 128 call VerifyScreenDump(buf, 'Test_conceal_cul_01', {}) 129 130 call term_sendkeys(buf, ":wincmd w\r") 131 call VerifyScreenDump(buf, 'Test_conceal_cul_02', {}) 132 133 call term_sendkeys(buf, "k") 134 call VerifyScreenDump(buf, 'Test_conceal_cul_03', {}) 135 136 " clean up 137 call StopVimInTerminal(buf) 138 endfunc 139 140 func Test_conceal_with_cursorcolumn() 141 CheckScreendump 142 143 " Check that cursorcolumn and colorcolumn don't get broken in presence of 144 " wrapped lines containing concealed text 145 let code =<< trim [CODE] 146 let lines = ["one one one |hidden| one one one one one one one one", 147 \ "two two two two |hidden| here two two", 148 \ "three |hidden| three three three three three three three three"] 149 call setline(1, lines) 150 set wrap linebreak 151 set showbreak=\ >>>\ 152 syntax match test /|hidden|/ conceal 153 set conceallevel=2 154 set concealcursor= 155 exe "normal /here\r" 156 set cursorcolumn 157 set colorcolumn=50 158 [CODE] 159 160 call writefile(code, 'XTest_conceal_cuc', 'D') 161 let buf = RunVimInTerminal('-S XTest_conceal_cuc', {'rows': 10, 'cols': 40}) 162 call VerifyScreenDump(buf, 'Test_conceal_cuc_01', {}) 163 164 " move cursor to the end of line (the cursor jumps to the next screen line) 165 call term_sendkeys(buf, "$") 166 call VerifyScreenDump(buf, 'Test_conceal_cuc_02', {}) 167 168 " clean up 169 call StopVimInTerminal(buf) 170 endfunc 171 172 " Check that 'cursorline' and 'wincolor' apply to the whole line in presence 173 " of wrapped lines containing concealed text. 174 func Test_conceal_wrapped_cursorline_wincolor() 175 CheckScreendump 176 177 let code =<< trim [CODE] 178 call setline(1, 'one one one |hidden| one one one one one one one one') 179 syntax match test /|hidden|/ conceal 180 set conceallevel=2 concealcursor=n cursorline 181 normal! g$ 182 [CODE] 183 184 call writefile(code, 'XTest_conceal_cul_wcr', 'D') 185 let buf = RunVimInTerminal('-S XTest_conceal_cul_wcr', {'rows': 4, 'cols': 40}) 186 call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_01', {}) 187 188 call term_sendkeys(buf, ":set wincolor=ErrorMsg\n") 189 call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_02', {}) 190 191 call term_sendkeys(buf, ":set nocursorline\n") 192 call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_03', {}) 193 194 " clean up 195 call StopVimInTerminal(buf) 196 endfunc 197 198 " Same as Test_conceal_wrapped_cursorline_wincolor(), but with 'rightleft'. 199 func Test_conceal_wrapped_cursorline_wincolor_rightleft() 200 CheckFeature rightleft 201 CheckScreendump 202 203 let code =<< trim [CODE] 204 call setline(1, 'one one one |hidden| one one one one one one one one') 205 syntax match test /|hidden|/ conceal 206 set conceallevel=2 concealcursor=n cursorline rightleft 207 normal! g$ 208 [CODE] 209 210 call writefile(code, 'XTest_conceal_cul_wcr_rl', 'D') 211 let buf = RunVimInTerminal('-S XTest_conceal_cul_wcr_rl', {'rows': 4, 'cols': 40}) 212 call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_rl_01', {}) 213 214 call term_sendkeys(buf, ":set wincolor=ErrorMsg\n") 215 call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_rl_02', {}) 216 217 call term_sendkeys(buf, ":set nocursorline\n") 218 call VerifyScreenDump(buf, 'Test_conceal_cul_wcr_rl_03', {}) 219 220 " clean up 221 call StopVimInTerminal(buf) 222 endfunc 223 224 func Test_conceal_resize_term() 225 CheckScreendump 226 227 let code =<< trim [CODE] 228 call setline(1, '`one` `two` `three` `four` `five`, the backticks should be concealed') 229 setl cocu=n cole=3 230 syn region CommentCodeSpan matchgroup=Comment start=/`/ end=/`/ concealends 231 normal fb 232 [CODE] 233 call writefile(code, 'XTest_conceal_resize', 'D') 234 let buf = RunVimInTerminal('-S XTest_conceal_resize', {'rows': 6}) 235 call VerifyScreenDump(buf, 'Test_conceal_resize_01', {}) 236 237 call win_execute(buf->win_findbuf()[0], 'wincmd +') 238 call VerifyScreenDump(buf, 'Test_conceal_resize_02', {}) 239 240 " clean up 241 call StopVimInTerminal(buf) 242 endfunc 243 244 func Test_conceal_linebreak() 245 CheckScreendump 246 247 let code =<< trim [CODE] 248 vim9script 249 &wrap = true 250 &conceallevel = 2 251 &concealcursor = 'nc' 252 &linebreak = true 253 &showbreak = '+ ' 254 var line: string = 'a`a`a`a`' 255 .. 'a'->repeat(&columns - 15) 256 .. ' b`b`' 257 .. 'b'->repeat(&columns - 10) 258 .. ' cccccc' 259 ['x'->repeat(&columns), '', line]->setline(1) 260 syntax region CodeSpan matchgroup=Delimiter start=/\z(`\+\)/ end=/\z1/ concealends 261 [CODE] 262 call writefile(code, 'XTest_conceal_linebreak', 'D') 263 let buf = RunVimInTerminal('-S XTest_conceal_linebreak', {'rows': 8}) 264 call VerifyScreenDump(buf, 'Test_conceal_linebreak_1', {}) 265 266 " clean up 267 call StopVimInTerminal(buf) 268 endfunc 269 270 " Tests for correct display (cursor column position) with +conceal and 271 " tabulators. Need to run this test in a separate Vim instance. Otherwise the 272 " screen is not updated (lazy redraw) and the cursor position is wrong. 273 func Test_conceal_cursor_pos() 274 let code =<< trim [CODE] 275 :let l = ['start:', '.concealed. text', "|concealed|\ttext"] 276 :let l += ['', "\t.concealed.\ttext", "\t|concealed|\ttext", ''] 277 :let l += [".a.\t.b.\t.c.\t.d.", "|a|\t|b|\t|c|\t|d|"] 278 :call append(0, l) 279 :call cursor(1, 1) 280 :" Conceal settings. 281 :set conceallevel=2 282 :set concealcursor=nc 283 :syntax match test /|/ conceal 284 :" Save current cursor position. Only works in <expr> mode, can't be used 285 :" with :normal because it moves the cursor to the command line. Thanks 286 :" to ZyX <zyx.vim@gmail.com> for the idea to use an <expr> mapping. 287 :let curpos = [] 288 :nnoremap <expr> GG ":let curpos += ['".screenrow().":".screencol()."']\n" 289 :normal ztj 290 GGk 291 :" We should end up in the same column when running these commands on the 292 :" two lines. 293 :normal ft 294 GGk 295 :normal $ 296 GGk 297 :normal 0j 298 GGk 299 :normal ft 300 GGk 301 :normal $ 302 GGk 303 :normal 0j0j 304 GGk 305 :" Same for next test block. 306 :normal ft 307 GGk 308 :normal $ 309 GGk 310 :normal 0j 311 GGk 312 :normal ft 313 GGk 314 :normal $ 315 GGk 316 :normal 0j0j 317 GGk 318 :" And check W with multiple tabs and conceals in a line. 319 :normal W 320 GGk 321 :normal W 322 GGk 323 :normal W 324 GGk 325 :normal $ 326 GGk 327 :normal 0j 328 GGk 329 :normal W 330 GGk 331 :normal W 332 GGk 333 :normal W 334 GGk 335 :normal $ 336 GGk 337 :set lbr 338 :normal $ 339 GGk 340 :set list listchars=tab:>- 341 :normal 0 342 GGk 343 :normal W 344 GGk 345 :normal W 346 GGk 347 :normal W 348 GGk 349 :normal $ 350 GGk 351 :call writefile(curpos, 'Xconceal_curpos.out') 352 :q! 353 354 [CODE] 355 call writefile(code, 'XTest_conceal_curpos', 'D') 356 357 if RunVim([], [], '-s XTest_conceal_curpos') 358 call assert_equal([ 359 \ '2:1', '2:17', '2:20', '3:1', '3:17', '3:20', '5:8', '5:25', 360 \ '5:28', '6:8', '6:25', '6:28', '8:1', '8:9', '8:17', '8:25', 361 \ '8:27', '9:1', '9:9', '9:17', '9:25', '9:26', '9:26', '9:1', 362 \ '9:9', '9:17', '9:25', '9:26'], readfile('Xconceal_curpos.out')) 363 endif 364 365 call delete('Xconceal_curpos.out') 366 endfunc 367 368 func Test_conceal_eol() 369 new! 370 setlocal concealcursor=n conceallevel=1 371 call setline(1, ["x", ""]) 372 call matchaddpos('Conceal', [[2, 1, 1]], 2, -1, {'conceal': 1}) 373 redraw! 374 375 call assert_notequal(screenchar(1, 1), screenchar(2, 2)) 376 call assert_equal(screenattr(1, 1), screenattr(1, 2)) 377 call assert_equal(screenattr(1, 2), screenattr(2, 2)) 378 call assert_equal(screenattr(2, 1), screenattr(2, 2)) 379 380 set list 381 redraw! 382 383 call assert_equal(screenattr(1, 1), screenattr(2, 2)) 384 call assert_notequal(screenattr(1, 1), screenattr(1, 2)) 385 call assert_notequal(screenattr(1, 2), screenattr(2, 1)) 386 387 set nolist 388 endfunc 389 390 func Test_conceal_mouse_click() 391 call NewWindow(10, 40) 392 set mouse=a 393 setlocal conceallevel=2 concealcursor=nc 394 syn match Concealed "this" conceal 395 hi link Concealed Search 396 397 " Nvim: need to redraw before processing every key, because mouse clicks set 398 " w_redr_type, which prevent using vcols[]. 399 lua _G.NS = vim.on_key(function() vim.cmd.redraw() end) 400 401 " Test with both 'nocursorline' and 'cursorline', as they use two different 402 " code paths to set virtual columns for the cells to clear. 403 for cul in [v:false, v:true] 404 let &l:cursorline = cul 405 406 call setline(1, 'conceal this click here') 407 call assert_equal([ 408 \ 'conceal click here ', 409 \ ], ScreenLines(1, 40)) 410 411 " Click on the space between "this" and "click" puts cursor there. 412 call Ntest_setmouse(1, 9) 413 call feedkeys("\<LeftMouse>", "tx") 414 call assert_equal([0, 1, 13, 0, 13], getcurpos()) 415 " Click on 'h' of "here" puts cursor there. 416 call Ntest_setmouse(1, 16) 417 call feedkeys("\<LeftMouse>", "tx") 418 call assert_equal([0, 1, 20, 0, 20], getcurpos()) 419 " Click on 'e' of "here" puts cursor there. 420 call Ntest_setmouse(1, 19) 421 call feedkeys("\<LeftMouse>", "tx") 422 call assert_equal([0, 1, 23, 0, 23], getcurpos()) 423 " Click after end of line puts cursor on 'e' without 'virtualedit'. 424 call Ntest_setmouse(1, 20) 425 call feedkeys("\<LeftMouse>", "tx") 426 call assert_equal([0, 1, 23, 0, 24], getcurpos()) 427 call Ntest_setmouse(1, 21) 428 call feedkeys("\<LeftMouse>", "tx") 429 call assert_equal([0, 1, 23, 0, 25], getcurpos()) 430 call Ntest_setmouse(1, 22) 431 call feedkeys("\<LeftMouse>", "tx") 432 call assert_equal([0, 1, 23, 0, 26], getcurpos()) 433 call Ntest_setmouse(1, 31) 434 call feedkeys("\<LeftMouse>", "tx") 435 call assert_equal([0, 1, 23, 0, 35], getcurpos()) 436 call Ntest_setmouse(1, 32) 437 call feedkeys("\<LeftMouse>", "tx") 438 call assert_equal([0, 1, 23, 0, 36], getcurpos()) 439 440 set virtualedit=all 441 redraw 442 " Click on the space between "this" and "click" puts cursor there. 443 call Ntest_setmouse(1, 9) 444 call feedkeys("\<LeftMouse>", "tx") 445 call assert_equal([0, 1, 13, 0, 13], getcurpos()) 446 " Click on 'h' of "here" puts cursor there. 447 call Ntest_setmouse(1, 16) 448 call feedkeys("\<LeftMouse>", "tx") 449 call assert_equal([0, 1, 20, 0, 20], getcurpos()) 450 " Click on 'e' of "here" puts cursor there. 451 call Ntest_setmouse(1, 19) 452 call feedkeys("\<LeftMouse>", "tx") 453 call assert_equal([0, 1, 23, 0, 23], getcurpos()) 454 " Click after end of line puts cursor there with 'virtualedit'. 455 call Ntest_setmouse(1, 20) 456 call feedkeys("\<LeftMouse>", "tx") 457 call assert_equal([0, 1, 24, 0, 24], getcurpos()) 458 call Ntest_setmouse(1, 21) 459 call feedkeys("\<LeftMouse>", "tx") 460 call assert_equal([0, 1, 24, 1, 25], getcurpos()) 461 call Ntest_setmouse(1, 22) 462 call feedkeys("\<LeftMouse>", "tx") 463 call assert_equal([0, 1, 24, 2, 26], getcurpos()) 464 call Ntest_setmouse(1, 31) 465 call feedkeys("\<LeftMouse>", "tx") 466 call assert_equal([0, 1, 24, 11, 35], getcurpos()) 467 call Ntest_setmouse(1, 32) 468 call feedkeys("\<LeftMouse>", "tx") 469 call assert_equal([0, 1, 24, 12, 36], getcurpos()) 470 " Behavior should also be the same with 'colorcolumn'. 471 setlocal colorcolumn=30 472 redraw 473 call Ntest_setmouse(1, 31) 474 call feedkeys("\<LeftMouse>", "tx") 475 call assert_equal([0, 1, 24, 11, 35], getcurpos()) 476 call Ntest_setmouse(1, 32) 477 call feedkeys("\<LeftMouse>", "tx") 478 call assert_equal([0, 1, 24, 12, 36], getcurpos()) 479 setlocal colorcolumn& 480 481 if has('rightleft') 482 setlocal rightleft 483 call assert_equal([ 484 \ ' ereh kcilc laecnoc', 485 \ ], ScreenLines(1, 40)) 486 " Click on the space between "this" and "click" puts cursor there. 487 call Ntest_setmouse(1, 41 - 9) 488 call feedkeys("\<LeftMouse>", "tx") 489 call assert_equal([0, 1, 13, 0, 13], getcurpos()) 490 " Click on 'h' of "here" puts cursor there. 491 call Ntest_setmouse(1, 41 - 16) 492 call feedkeys("\<LeftMouse>", "tx") 493 call assert_equal([0, 1, 20, 0, 20], getcurpos()) 494 " Click on 'e' of "here" puts cursor there. 495 call Ntest_setmouse(1, 41 - 19) 496 call feedkeys("\<LeftMouse>", "tx") 497 call assert_equal([0, 1, 23, 0, 23], getcurpos()) 498 " Click after end of line puts cursor there with 'virtualedit'. 499 call Ntest_setmouse(1, 41 - 20) 500 call feedkeys("\<LeftMouse>", "tx") 501 call assert_equal([0, 1, 24, 0, 24], getcurpos()) 502 call Ntest_setmouse(1, 41 - 21) 503 call feedkeys("\<LeftMouse>", "tx") 504 call assert_equal([0, 1, 24, 1, 25], getcurpos()) 505 call Ntest_setmouse(1, 41 - 22) 506 call feedkeys("\<LeftMouse>", "tx") 507 call assert_equal([0, 1, 24, 2, 26], getcurpos()) 508 call Ntest_setmouse(1, 41 - 31) 509 call feedkeys("\<LeftMouse>", "tx") 510 call assert_equal([0, 1, 24, 11, 35], getcurpos()) 511 call Ntest_setmouse(1, 41 - 32) 512 call feedkeys("\<LeftMouse>", "tx") 513 call assert_equal([0, 1, 24, 12, 36], getcurpos()) 514 setlocal rightleft& 515 endif 516 517 set virtualedit& 518 519 " Test with a wrapped line. 520 call setline(1, ['conceal this click here']->repeat(3)->join()) 521 call assert_equal([ 522 \ 'conceal click here conceal cli ', 523 \ 'ck here conceal click here ', 524 \ ], ScreenLines([1, 2], 40)) 525 " Click on boguscols puts cursor on the last char of a screen line. 526 for col in range(33, 40) 527 call Ntest_setmouse(1, col) 528 call feedkeys("\<LeftMouse>", "tx") 529 call assert_equal([0, 1, 40, 0, 40], getcurpos()) 530 endfor 531 532 " Also test with the last char of a screen line concealed. 533 setlocal number signcolumn=yes 534 call assert_equal([ 535 \ ' 1 conceal click here conceal ', 536 \ ' click here conceal click h ', 537 \ ' ere ', 538 \ ], ScreenLines([1, 3], 40)) 539 call Ntest_setmouse(1, 34) 540 call feedkeys("\<LeftMouse>", "tx") 541 call assert_equal([0, 1, 32, 0, 32], getcurpos()) 542 call Ntest_setmouse(2, 7) 543 call feedkeys("\<LeftMouse>", "tx") 544 call assert_equal([0, 1, 37, 0, 37], getcurpos()) 545 " Click on boguscols puts cursor on the last char of a screen line. 546 for col in range(35, 40) 547 call Ntest_setmouse(1, col) 548 call feedkeys("\<LeftMouse>", "tx") 549 call assert_equal([0, 1, 34, 0, 34], getcurpos()) 550 call Ntest_setmouse(2, col) 551 call feedkeys("\<LeftMouse>", "tx") 552 call assert_equal([0, 1, 68, 0, 68], getcurpos()) 553 endfor 554 setlocal number& signcolumn& 555 endfor 556 557 lua vim.on_key(nil, _G.NS); _G.NS = nil 558 559 call CloseWindow() 560 set mouse& 561 endfunc 562 563 " Test that cursor is drawn at the correct column when it is after end of the 564 " line with 'virtualedit' and concealing. 565 func Run_test_conceal_virtualedit_after_eol(wrap) 566 CheckScreendump 567 568 let code =<< trim eval [CODE] 569 let &wrap = {a:wrap} 570 call setline(1, 'abcdefgh|hidden|ijklmnpop') 571 syntax match test /|hidden|/ conceal 572 set conceallevel=2 concealcursor=n virtualedit=all 573 normal! $ 574 [CODE] 575 call writefile(code, 'XTest_conceal_ve_after_eol', 'D') 576 let buf = RunVimInTerminal('-S XTest_conceal_ve_after_eol', {'rows': 3}) 577 call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_1', {}) 578 call term_sendkeys(buf, "l") 579 call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_2', {}) 580 call term_sendkeys(buf, "l") 581 call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_3', {}) 582 call term_sendkeys(buf, "l") 583 call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_4', {}) 584 call term_sendkeys(buf, "rr") 585 call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_5', {}) 586 587 " clean up 588 call StopVimInTerminal(buf) 589 endfunc 590 591 func Test_conceal_virtualedit_after_eol() 592 CheckScreendump 593 594 call Run_test_conceal_virtualedit_after_eol(1) 595 call Run_test_conceal_virtualedit_after_eol(0) 596 endfunc 597 598 " Same as Run_test_conceal_virtualedit_after_eol(), but with 'rightleft'. 599 func Run_test_conceal_virtualedit_after_eol_rightleft(wrap) 600 CheckScreendump 601 602 let code =<< trim eval [CODE] 603 let &wrap = {a:wrap} 604 call setline(1, 'abcdefgh|hidden|ijklmnpop') 605 syntax match test /|hidden|/ conceal 606 set conceallevel=2 concealcursor=n virtualedit=all rightleft 607 normal! $ 608 [CODE] 609 call writefile(code, 'XTest_conceal_ve_after_eol_rl', 'D') 610 let buf = RunVimInTerminal('-S XTest_conceal_ve_after_eol_rl', {'rows': 3}) 611 call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_1', {}) 612 call term_sendkeys(buf, "h") 613 call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_2', {}) 614 call term_sendkeys(buf, "h") 615 call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_3', {}) 616 call term_sendkeys(buf, "h") 617 call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_4', {}) 618 call term_sendkeys(buf, "rr") 619 call VerifyScreenDump(buf, 'Test_conceal_ve_after_eol_rl_5', {}) 620 621 " clean up 622 call StopVimInTerminal(buf) 623 endfunc 624 625 func Test_conceal_virtualedit_after_eol_rightleft() 626 CheckFeature rightleft 627 CheckScreendump 628 629 call Run_test_conceal_virtualedit_after_eol_rightleft(1) 630 call Run_test_conceal_virtualedit_after_eol_rightleft(0) 631 endfunc 632 633 " Test that cursor position is correct when double-width chars are concealed. 634 func Run_test_conceal_double_width(wrap) 635 CheckScreendump 636 637 let code =<< trim eval [CODE] 638 let &wrap = {a:wrap} 639 call setline(1, ['aaaaa口=口bbbbb口=口ccccc', 'foobar']) 640 syntax match test /口=口/ conceal cchar=β 641 set conceallevel=2 concealcursor=n colorcolumn=30 642 normal! $ 643 [CODE] 644 call writefile(code, 'XTest_conceal_double_width', 'D') 645 let buf = RunVimInTerminal('-S XTest_conceal_double_width', {'rows': 4}) 646 call VerifyScreenDump(buf, 'Test_conceal_double_width_1', {}) 647 call term_sendkeys(buf, "gM") 648 call VerifyScreenDump(buf, 'Test_conceal_double_width_2', {}) 649 call term_sendkeys(buf, ":set conceallevel=3\<CR>") 650 call VerifyScreenDump(buf, 'Test_conceal_double_width_3', {}) 651 call term_sendkeys(buf, "$") 652 call VerifyScreenDump(buf, 'Test_conceal_double_width_4', {}) 653 654 " clean up 655 call StopVimInTerminal(buf) 656 endfunc 657 658 func Test_conceal_double_width() 659 CheckScreendump 660 661 call Run_test_conceal_double_width(1) 662 call Run_test_conceal_double_width(0) 663 endfunc 664 665 " Test that line wrapping is correct when double-width chars are concealed. 666 func Test_conceal_double_width_wrap() 667 CheckScreendump 668 669 let code =<< trim [CODE] 670 call setline(1, 'aaaaaaaaaa口=口bbbbbbbbbb口=口cccccccccc') 671 syntax match test /口=口/ conceal cchar=β 672 set conceallevel=2 concealcursor=n 673 normal! $ 674 [CODE] 675 call writefile(code, 'XTest_conceal_double_width_wrap', 'D') 676 let buf = RunVimInTerminal('-S XTest_conceal_double_width_wrap', {'rows': 4, 'cols': 20}) 677 call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_1', {}) 678 call term_sendkeys(buf, "gM") 679 call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_2', {}) 680 call term_sendkeys(buf, ":set conceallevel=3\<CR>") 681 call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_3', {}) 682 call term_sendkeys(buf, "$") 683 call VerifyScreenDump(buf, 'Test_conceal_double_width_wrap_4', {}) 684 685 " clean up 686 call StopVimInTerminal(buf) 687 endfunc 688 689 " vim: shiftwidth=2 sts=2 expandtab