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