robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1local n =require ( 'test.functional.testnvim' )() 2local t =require ( 'test.testutil' ) 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each =t . describe , t . it , t . before_each 6local clear =n . clear 7local exec =n . exec 8local feed =n . feed 9local command =n . command 10 11describe ( 'display' , function () 12before_each ( clear ) 13 14-- oldtest: Test_display_scroll_at_topline() 15it ( 'scroll when modified at topline vim-patch:8.2.1488' , function () 16local screen =Screen . new ( 20 , 4 ) 17command ( [[call setline(1, repeat('a', 21))]] ) 18feed ( 'O' ) 19screen : expect ( [[ 20^ | 21aaaaaaaaaaaaaaaaaaaa| 22a | 23{5:-- INSERT --} | 24]] ) 25end ) 26 27-- oldtest: Test_display_scroll_update_visual() 28it ( 'scrolling when modified at topline in Visual mode vim-patch:8.2.4626' , function () 29local screen =Screen . new ( 60 , 8 ) 30exec ( [[ 31set scrolloff=0 32call setline(1, repeat(['foo'], 10)) 33call sign_define('foo', { 'text': '>' }) 34call sign_place(1, 'bar', 'foo', bufnr(), { 'lnum': 2 }) 35call sign_place(2, 'bar', 'foo', bufnr(), { 'lnum': 1 }) 36autocmd CursorMoved * if getcurpos()[1] == 2 | call sign_unplace('bar', { 'id': 1 }) | endif 37]] ) 38feed ( 'VG7kk' ) 39screen : expect ( [[ 40{7: }{17:^foo} | 41{7: }foo |*6 42{5:-- VISUAL LINE --} | 43]] ) 44end ) 45 46-- oldtest: Test_display_scroll_setline() 47it ( 'scrolling with sign_unplace() and setline() in CursorMoved' , function () 48local screen =Screen . new ( 20 , 15 ) 49exec ( [[ 50setlocal scrolloff=5 signcolumn=yes 51call setline(1, range(1, 100)) 52call sign_define('foo', #{text: '>'}) 53call sign_place(1, 'bar', 'foo', bufnr(), #{lnum: 71}) 54call sign_place(2, 'bar', 'foo', bufnr(), #{lnum: 72}) 55call sign_place(3, 'bar', 'foo', bufnr(), #{lnum: 73}) 56call sign_place(4, 'bar', 'foo', bufnr(), #{lnum: 74}) 57call sign_place(5, 'bar', 'foo', bufnr(), #{lnum: 75}) 58normal! G 59autocmd CursorMoved * if line('.') == 79 60\ | call sign_unplace('bar', #{id: 4}) 61\ | call setline(80, repeat('foo', 15)) 62\ | elseif line('.') == 78 63\ | call setline(72, repeat('bar', 10)) 64\ | elseif line('.') == 77 65\ | call sign_unplace('bar', #{id: 2}) 66\ | endif 67]] ) 68screen : expect ( [[ 69{7: }87 | 70{7: }88 | 71{7: }89 | 72{7: }90 | 73{7: }91 | 74{7: }92 | 75{7: }93 | 76{7: }94 | 77{7: }95 | 78{7: }96 | 79{7: }97 | 80{7: }98 | 81{7: }99 | 82{7: }^100 | 83| 84]] ) 85feed ( '19k' ) 86screen : expect ( [[ 87{7:> }75 | 88{7: }76 | 89{7: }77 | 90{7: }78 | 91{7: }79 | 92{7: }80 | 93{7: }^81 | 94{7: }82 | 95{7: }83 | 96{7: }84 | 97{7: }85 | 98{7: }86 | 99{7: }87 | 100{7: }88 | 101| 102]] ) 103feed ( 'k' ) 104screen : expect ( [[ 105{7:> }75 | 106{7: }76 | 107{7: }77 | 108{7: }78 | 109{7: }79 | 110{7: }^80 | 111{7: }81 | 112{7: }82 | 113{7: }83 | 114{7: }84 | 115{7: }85 | 116{7: }86 | 117{7: }87 | 118{7: }88 | 119| 120]] ) 121feed ( 'k' ) 122screen : expect ( [[ 123{7: }74 | 124{7:> }75 | 125{7: }76 | 126{7: }77 | 127{7: }78 | 128{7: }^79 | 129{7: }foofoofoofoofoofoo|*2 130{7: }foofoofoo | 131{7: }81 | 132{7: }82 | 133{7: }83 | 134{7: }84 | 135{7: }85 | 136| 137]] ) 138feed ( 'k' ) 139screen : expect ( [[ 140{7:> }73 | 141{7: }74 | 142{7:> }75 | 143{7: }76 | 144{7: }77 | 145{7: }^78 | 146{7: }79 | 147{7: }foofoofoofoofoofoo|*2 148{7: }foofoofoo | 149{7: }81 | 150{7: }82 | 151{7: }83 | 152{7: }84 | 153| 154]] ) 155feed ( 'k' ) 156screen : expect ( [[ 157{7: }barbarbarbarbarbar| 158{7: }barbarbarbar | 159{7:> }73 | 160{7: }74 | 161{7:> }75 | 162{7: }76 | 163{7: }^77 | 164{7: }78 | 165{7: }79 | 166{7: }foofoofoofoofoofoo|*2 167{7: }foofoofoo | 168{7: }81 | 169{7: }82 | 170| 171]] ) 172end ) 173 174-- oldtest: Test_display_hit_enter_setline() 175it ( 'using setline() at hit-enter prompt' , function () 176local screen =Screen . new ( 40 , 8 ) 177exec ( [[ 178call setline(1, range(1, 100)) 179]] ) 180screen : expect ( [[ 181^1 | 1822 | 1833 | 1844 | 1855 | 1866 | 1877 | 188| 189]] ) 190feed ( [[:echo "abc\ndef\nghi"<CR>]] ) 191screen : expect ( [[ 1921 | 1932 | 1943 | 195{3: }| 196abc | 197def | 198ghi | 199{6:Press ENTER or type command to continue}^ | 200]] ) 201feed ( [[:call setline(2, repeat('foo', 35))<CR>]] ) 202screen : expect ( [[ 203^1 | 204foofoofoofoofoofoofoofoofoofoofoofoofoof| 205oofoofoofoofoofoofoofoofoofoofoofoofoofo| 206ofoofoofoofoofoofoofoofoo | 2073 | 2084 | 2095 | 210| 211]] ) 212end ) 213 214local function run_test_display_lastline ( euro ) 215local screen =Screen . new ( 75 , 10 ) 216exec ( [[ 217call setline(1, ['aaa', 'b'->repeat(200)]) 218set display=truncate 219 220vsplit 221100wincmd < 222]] ) 223local fillchar ='@' 224if euro then 225command ( 'set fillchars=lastline:€' ) 226fillchar ='€' 227end 228screen : expect ((( [[ 229^a│aaa | 230a│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*2 231b│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | 232b│{1:~ }|*3 233{1:@}│{1:~ }| 234{3:< }{2:[No Name] [+] }| 235| 236]] ): gsub ( '@' , fillchar ))) 237 238command ( 'set display=lastline' ) 239screen : expect_unchanged () 240 241command ( '100wincmd >' ) 242screen : expect ((( [[ 243^aaa │a| 244bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb│a|*2 245bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb │b| 246{1:~ }│b|*3 247{1:~ }│{1:@}| 248{3:[No Name] [+] }{2:<}| 249| 250]] ): gsub ( '@' , fillchar ))) 251 252command ( 'set display=truncate' ) 253screen : expect_unchanged () 254 255command ( 'close' ) 256command ( '3split' ) 257screen : expect ((( [[ 258^aaa | 259bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| 260{1:@@@ }| 261{3:[No Name] [+] }| 262aaa | 263bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*2 264bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | 265{2:[No Name] [+] }| 266| 267]] ): gsub ( '@' , fillchar ))) 268 269command ( 'close' ) 270command ( '2vsplit' ) 271screen : expect ((( [[ 272^aa│aaa | 273a │bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| 274bb│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| 275bb│bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | 276bb│{1:~ }|*3 277{1:@@}│{1:~ }| 278{3:< }{2:[No Name] [+] }| 279| 280]] ): gsub ( '@' , fillchar ))) 281end 282 283-- oldtest: Test_display_lastline() 284it ( 'display "lastline" works correctly' , function () 285run_test_display_lastline () 286end ) 287it ( 'display "lastline" works correctly with multibyte fillchar' , function () 288run_test_display_lastline ( true ) 289end ) 290 291-- oldtest: Test_display_long_lastline() 292it ( '"lastline" shows correct text when end of wrapped line is deleted' , function () 293local screen =Screen . new ( 35 , 14 ) 294exec ( [[ 295set display=lastline smoothscroll scrolloff=0 296call setline(1, [ 297\'aaaaa'->repeat(150), 298\'bbbbb '->repeat(7) .. 'ccccc '->repeat(7) .. 'ddddd '->repeat(7) 299\]) 300]] ) 301feed ( '736|' ) 302screen : expect ( [[ 303{1:<<<}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 304aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*11 305^aaaaaaaaaaaaaaa | 306| 307]] ) 308-- The correct part of the last line is moved into view. 309feed ( 'D' ) 310screen : expect ( [[ 311{1:<<<}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| 312aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*10 313aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^a| 314bbbbb bbbbb bbbbb bbbbb bbbbb bb{1:@@@}| 315| 316]] ) 317-- "w_skipcol" does not change because the topline is still long enough 318-- to maintain the current skipcol. 319feed ( 'g04l11gkD' ) 320screen : expect ( [[ 321{1:<<<}^a | 322bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb| 323bbbbb ccccc ccccc ccccc ccccc cccc| 324c ccccc ccccc ddddd ddddd ddddd ddd| 325dd ddddd ddddd ddddd | 326{1:~ }|*8 327| 328]] ) 329-- "w_skipcol" is reset to bring the entire topline into view because 330-- the line length is now smaller than the current skipcol + marker. 331feed ( 'x' ) 332screen : expect ( [[ 333aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*9 334aa^a | 335bbbbb bbbbb bbbbb bbbbb bbbbb bbbbb| 336bbbbb ccccc ccccc ccccc ccccc cccc| 337c ccccc ccccc ddddd ddddd ddddd {1:@@@}| 338| 339]] ) 340end ) 341 342-- oldtest: Test_display_cursor_long_line() 343it ( "correctly shows line that doesn't fit in the window" , function () 344local screen =Screen . new ( 75 , 8 ) 345exec ( [[ 346call setline(1, ['a', 'b ' .. 'bbbbb'->repeat(150), 'c']) 347norm $j 348]] ) 349screen : expect ( [[ 350{1:<<<}bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| 351bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*5 352b^b | 353| 354]] ) 355-- FIXME: moving the cursor above the topline does not set w_skipcol 356-- correctly with cpo+=n and zero scrolloff (curs_columns() extra == 1). 357exec ( 'set number cpo+=n scrolloff=0' ) 358feed ( '$0' ) 359screen : expect ( [[ 360{1:<<<}b^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| 361bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*6 362| 363]] ) 364-- Going to the start of the line with "b" did not set w_skipcol correctly with 'smoothscroll'. 365exec ( 'set smoothscroll' ) 366feed ( '$b' ) 367screen : expect ( [[ 368{8: 2 }b ^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| 369bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*6 370| 371]] ) 372-- Same for "ge". 373feed ( '$ge' ) 374screen : expect ( [[ 375{8: 2 }^b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| 376bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*6 377| 378]] ) 379end ) 380 381-- oldtest: Test_change_wrapped_line_cpo_dollar() 382it ( 'changing wrapped line with cpo+=$' , function () 383local screen =Screen . new ( 45 , 10 ) 384exec ( [[ 385set cpoptions+=$ laststatus=0 386call setline(1, ['foo', 'bar', 387\ repeat('x', 25) .. '!!()!!' .. repeat('y', 25), 388\ 'FOO', 'BAR']) 389inoremap <F2> <Cmd>call setline(1, repeat('z', 30))<CR> 390inoremap <F3> <Cmd>call setline(1, 'foo')<CR> 391vsplit 392call cursor(3, 1) 393]] ) 394 395local s1 =[[ 396foo │foo | 397bar │bar | 398^xxxxxxxxxxxxxxxxxxxxxx│xxxxxxxxxxxxxxxxxxxxxx| 399xxx!!()!!yyyyyyyyyyyyy│xxx!!()!!yyyyyyyyyyyyy| 400yyyyyyyyyyyy │yyyyyyyyyyyy | 401FOO │FOO | 402BAR │BAR | 403{1:~ }│{1:~ }|*2 404| 405]] 406screen : expect ( s1 ) 407feed ( 'ct!' ) 408local s2 =[[ 409foo │foo | 410bar │bar | 411^xxxxxxxxxxxxxxxxxxxxxx│!!()!!yyyyyyyyyyyyyyyy| 412xx$!!()!!yyyyyyyyyyyyy│yyyyyyyyy | 413yyyyyyyyyyyy │FOO | 414FOO │BAR | 415BAR │{1:~ }| 416{1:~ }│{1:~ }|*2 417{5:-- INSERT --} | 418]] 419screen : expect ( s2 ) 420feed ( '<F2>' ) 421screen : expect ( [[ 422zzzzzzzzzzzzzzzzzzzzzz│zzzzzzzzzzzzzzzzzzzzzz| 423zzzzzzzz │zzzzzzzz | 424bar │bar | 425^xxxxxxxxxxxxxxxxxxxxxx│!!()!!yyyyyyyyyyyyyyyy| 426xx$!!()!!yyyyyyyyyyyyy│yyyyyyyyy | 427yyyyyyyyyyyy │FOO | 428FOO │BAR | 429BAR │{1:~ }| 430{1:~ }│{1:~ }| 431{5:-- INSERT --} | 432]] ) 433feed ( '<F3>' ) 434screen : expect ( s2 ) 435feed ( 'y' ) 436screen : expect ( [[ 437foo │foo | 438bar │bar | 439y^xxxxxxxxxxxxxxxxxxxxx│y!!()!!yyyyyyyyyyyyyyy| 440xx$!!()!!yyyyyyyyyyyyy│yyyyyyyyyy | 441yyyyyyyyyyyy │FOO | 442FOO │BAR | 443BAR │{1:~ }| 444{1:~ }│{1:~ }|*2 445{5:-- INSERT --} | 446]] ) 447feed ( 'y' ) 448screen : expect ( [[ 449foo │foo | 450bar │bar | 451yy^xxxxxxxxxxxxxxxxxxxx│yy!!()!!yyyyyyyyyyyyyy| 452xx$!!()!!yyyyyyyyyyyyy│yyyyyyyyyyy | 453yyyyyyyyyyyy │FOO | 454FOO │BAR | 455BAR │{1:~ }| 456{1:~ }│{1:~ }|*2 457{5:-- INSERT --} | 458]] ) 459feed ( '<Esc>' ) 460screen : expect ( [[ 461foo │foo | 462bar │bar | 463y^y!!()!!yyyyyyyyyyyyyy│yy!!()!!yyyyyyyyyyyyyy| 464yyyyyyyyyyy │yyyyyyyyyyy | 465FOO │FOO | 466BAR │BAR | 467{1:~ }│{1:~ }|*3 468| 469]] ) 470 471command ( 'silent undo' ) 472screen : expect ( s1 ) 473command ( 'source test/old/testdir/samples/matchparen.vim' ) 474feed ( 'ct(' ) 475screen : expect ( [[ 476foo │foo | 477bar │bar | 478^xxxxxxxxxxxxxxxxxxxxxx│()!!yyyyyyyyyyyyyyyyyy| 479xxx!$()!!yyyyyyyyyyyyy│yyyyyyy | 480yyyyyyyyyyyy │FOO | 481FOO │BAR | 482BAR │{1:~ }| 483{1:~ }│{1:~ }|*2 484{5:-- INSERT --} | 485]] ) 486feed ( 'y' ) 487screen : expect ( [[ 488foo │foo | 489bar │bar | 490y^xxxxxxxxxxxxxxxxxxxxx│y()!!yyyyyyyyyyyyyyyyy| 491xxx!$()!!yyyyyyyyyyyyy│yyyyyyyy | 492yyyyyyyyyyyy │FOO | 493FOO │BAR | 494BAR │{1:~ }| 495{1:~ }│{1:~ }|*2 496{5:-- INSERT --} | 497]] ) 498feed ( 'y' ) 499screen : expect ( [[ 500foo │foo | 501bar │bar | 502yy^xxxxxxxxxxxxxxxxxxxx│yy()!!yyyyyyyyyyyyyyyy| 503xxx!$()!!yyyyyyyyyyyyy│yyyyyyyyy | 504yyyyyyyyyyyy │FOO | 505FOO │BAR | 506BAR │{1:~ }| 507{1:~ }│{1:~ }|*2 508{5:-- INSERT --} | 509]] ) 510feed ( '<Esc>' ) 511screen : expect ( [[ 512foo │foo | 513bar │bar | 514y^y()!!yyyyyyyyyyyyyyyy│yy()!!yyyyyyyyyyyyyyyy| 515yyyyyyyyy │yyyyyyyyy | 516FOO │FOO | 517BAR │BAR | 518{1:~ }│{1:~ }|*3 519| 520]] ) 521 522command ( 'silent undo' ) 523screen : expect ( s1 ) 524feed ( 'f(azz<CR>zz<Esc>k0' ) 525screen : expect ( [[ 526foo │foo | 527bar │bar | 528^xxxxxxxxxxxxxxxxxxxxxx│xxxxxxxxxxxxxxxxxxxxxx| 529xxx!!(zz │xxx!!(zz | 530zz)!!yyyyyyyyyyyyyyyyy│zz)!!yyyyyyyyyyyyyyyyy| 531yyyyyyyy │yyyyyyyy | 532FOO │FOO | 533BAR │BAR | 534{1:~ }│{1:~ }| 535| 536]] ) 537feed ( 'ct(' ) 538screen : expect ( [[ 539foo │foo | 540bar │bar | 541^xxxxxxxxxxxxxxxxxxxxxx│(zz | 542xxx!$(zz │zz)!!yyyyyyyyyyyyyyyyy| 543zz)!!yyyyyyyyyyyyyyyyy│yyyyyyyy | 544yyyyyyyy │FOO | 545FOO │BAR | 546BAR │{1:~ }| 547{1:~ }│{1:~ }| 548{5:-- INSERT --} | 549]] ) 550feed ( 'y' ) 551screen : expect ( [[ 552foo │foo | 553bar │bar | 554y^xxxxxxxxxxxxxxxxxxxxx│y(zz | 555xxx!$(zz │zz)!!yyyyyyyyyyyyyyyyy| 556zz)!!yyyyyyyyyyyyyyyyy│yyyyyyyy | 557yyyyyyyy │FOO | 558FOO │BAR | 559BAR │{1:~ }| 560{1:~ }│{1:~ }| 561{5:-- INSERT --} | 562]] ) 563feed ( 'y' ) 564screen : expect ( [[ 565foo │foo | 566bar │bar | 567yy^xxxxxxxxxxxxxxxxxxxx│yy(zz | 568xxx!$(zz │zz)!!yyyyyyyyyyyyyyyyy| 569zz)!!yyyyyyyyyyyyyyyyy│yyyyyyyy | 570yyyyyyyy │FOO | 571FOO │BAR | 572BAR │{1:~ }| 573{1:~ }│{1:~ }| 574{5:-- INSERT --} | 575]] ) 576feed ( '<Esc>' ) 577screen : expect ( [[ 578foo │foo | 579bar │bar | 580y^y(zz │yy(zz | 581zz)!!yyyyyyyyyyyyyyyyy│zz)!!yyyyyyyyyyyyyyyyy| 582yyyyyyyy │yyyyyyyy | 583FOO │FOO | 584BAR │BAR | 585{1:~ }│{1:~ }|*2 586| 587]] ) 588end ) 589end )