robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each =t . describe , t . it , t . before_each 6local clear , feed , eq =n . clear , n . feed , t . eq 7local command =n . command 8local feed_command =n . feed_command 9local insert =n . insert 10local fn =n . fn 11local api =n . api 12local exec =n . exec 13local assert_alive =n . assert_alive 14 15local content1 =[[ 16This is a 17valid English 18sentence composed by 19an exhausted developer 20in his cave. 21]] 22 23describe ( 'folded lines' , function () 24before_each ( function () 25clear () 26command ( 'hi VertSplit gui=reverse' ) 27end ) 28 29local function with_ext_multigrid ( multigrid ) 30local screen 31before_each ( function () 32screen =Screen . new ( 45 , 8 , { rgb =true , ext_multigrid =multigrid } ) 33screen : add_extra_attr_ids ( { 34[ 100 ] ={ foreground =Screen . colors . Red } , 35[ 101 ] ={ foreground =Screen . colors . Red , background =Screen . colors . LightGrey } , 36[ 102 ] ={ underline =true } , 37[ 103 ] ={ foreground =Screen . colors . Blue4 , background =Screen . colors . Red } , 38[ 104 ] ={ 39bold =true , 40background =Screen . colors . LightGray , 41foreground =Screen . colors . Blue1 , 42} , 43[ 105 ] ={ background =Screen . colors . Yellow1 , foreground =Screen . colors . Blue4 } , 44[ 106 ] ={ bold =true , background =Screen . colors . Red , foreground =Screen . colors . Blue1 } , 45[ 107 ] ={ background =Screen . colors . LightGrey , foreground =Screen . colors . WebGreen } , 46[ 108 ] ={ foreground =Screen . colors . Green , background =Screen . colors . Red } , 47[ 109 ] ={ foreground =Screen . colors . Blue , bold =true , background =Screen . colors . Yellow1 } , 48} ) 49end ) 50 51it ( 'with more than one signcolumn' , function () 52command ( 'set signcolumn=yes:9' ) 53feed ( 'i<cr><esc>' ) 54feed ( 'vkzf' ) 55if multigrid then 56screen : expect ( [[ 57## grid 1 58[2:---------------------------------------------]|*7 59[3:---------------------------------------------]| 60## grid 2 61{7: }{13:^+-- 2 lines: ·············}| 62{1:~ }|*6 63## grid 3 64| 65]] ) 66else 67screen : expect ( [[ 68{7: }{13:^+-- 2 lines: ·············}| 69{1:~ }|*6 70| 71]] ) 72end 73end ) 74 75local function test_folded_cursorline ( foldtext ) 76if not foldtext then 77command ( 'set foldtext=' ) 78end 79command ( 'set number cursorline foldcolumn=2' ) 80command ( 'hi link CursorLineFold Search' ) 81insert ( content1 ) 82feed ( 'ggzf3jj' ) 83 84if multigrid then 85if foldtext then 86screen : expect ( [[ 87## grid 1 88[2:---------------------------------------------]|*7 89[3:---------------------------------------------]| 90## grid 2 91{7:+ }{8: 1 }{13:+-- 4 lines: This is a················}| 92{10: }{15: 5 }{100:^in his cave. }| 93{7: }{8: 6 } | 94{1:~ }|*4 95## grid 3 96| 97]] ) 98else 99screen : expect ( [[ 100## grid 1 101[2:---------------------------------------------]|*7 102[3:---------------------------------------------]| 103## grid 2 104{7:+ }{8: 1 }{13:This is a······························}| 105{10: }{15: 5 }{100:^in his cave. }| 106{7: }{8: 6 } | 107{1:~ }|*4 108## grid 3 109| 110]] ) 111end 112else 113if foldtext then 114screen : expect ( [[ 115{7:+ }{8: 1 }{13:+-- 4 lines: This is a················}| 116{10: }{15: 5 }{100:^in his cave. }| 117{7: }{8: 6 } | 118{1:~ }|*4 119| 120]] ) 121else 122screen : expect ( [[ 123{7:+ }{8: 1 }{13:This is a······························}| 124{10: }{15: 5 }{100:^in his cave. }| 125{7: }{8: 6 } | 126{1:~ }|*4 127| 128]] ) 129end 130end 131 132feed ( 'k' ) 133 134if multigrid then 135if foldtext then 136screen : expect ( [[ 137## grid 1 138[2:---------------------------------------------]|*7 139[3:---------------------------------------------]| 140## grid 2 141{10:+ }{15: 1 }{101:^+-- 4 lines: This is a················}| 142{7: }{8: 5 }in his cave. | 143{7: }{8: 6 } | 144{1:~ }|*4 145## grid 3 146| 147]] ) 148else 149screen : expect ( [[ 150## grid 1 151[2:---------------------------------------------]|*7 152[3:---------------------------------------------]| 153## grid 2 154{10:+ }{15: 1 }{101:^This is a······························}| 155{7: }{8: 5 }in his cave. | 156{7: }{8: 6 } | 157{1:~ }|*4 158## grid 3 159| 160]] ) 161end 162else 163if foldtext then 164screen : expect ( [[ 165{10:+ }{15: 1 }{101:^+-- 4 lines: This is a················}| 166{7: }{8: 5 }in his cave. | 167{7: }{8: 6 } | 168{1:~ }|*4 169| 170]] ) 171else 172screen : expect ( [[ 173{10:+ }{15: 1 }{101:^This is a······························}| 174{7: }{8: 5 }in his cave. | 175{7: }{8: 6 } | 176{1:~ }|*4 177| 178]] ) 179end 180end 181 182-- CursorLine is applied correctly with screenrow motions #22232 183feed ( 'jgk' ) 184screen : expect_unchanged () 185-- CursorLine is applied correctly when closing a fold when cursor is not at fold start 186feed ( 'zo4Gzc' ) 187screen : expect_unchanged () 188command ( 'set cursorlineopt=line' ) 189 190if multigrid then 191if foldtext then 192screen : expect ( [[ 193## grid 1 194[2:---------------------------------------------]|*7 195[3:---------------------------------------------]| 196## grid 2 197{10:+ }{8: 1 }{101:^+-- 4 lines: This is a················}| 198{7: }{8: 5 }in his cave. | 199{7: }{8: 6 } | 200{1:~ }|*4 201## grid 3 202| 203]] ) 204else 205screen : expect ( [[ 206## grid 1 207[2:---------------------------------------------]|*7 208[3:---------------------------------------------]| 209## grid 2 210{10:+ }{8: 1 }{101:^This is a······························}| 211{7: }{8: 5 }in his cave. | 212{7: }{8: 6 } | 213{1:~ }|*4 214## grid 3 215| 216]] ) 217end 218else 219if foldtext then 220screen : expect ( [[ 221{10:+ }{8: 1 }{101:^+-- 4 lines: This is a················}| 222{7: }{8: 5 }in his cave. | 223{7: }{8: 6 } | 224{1:~ }|*4 225| 226]] ) 227else 228screen : expect ( [[ 229{10:+ }{8: 1 }{101:^This is a······························}| 230{7: }{8: 5 }in his cave. | 231{7: }{8: 6 } | 232{1:~ }|*4 233| 234]] ) 235end 236end 237 238command ( 'set relativenumber cursorlineopt=number' ) 239 240if multigrid then 241if foldtext then 242screen : expect ( [[ 243## grid 1 244[2:---------------------------------------------]|*7 245[3:---------------------------------------------]| 246## grid 2 247{10:+ }{15:1 }{13:^+-- 4 lines: This is a················}| 248{7: }{8: 1 }in his cave. | 249{7: }{8: 2 } | 250{1:~ }|*4 251## grid 3 252| 253]] ) 254else 255screen : expect ( [[ 256## grid 1 257[2:---------------------------------------------]|*7 258[3:---------------------------------------------]| 259## grid 2 260{10:+ }{15:1 }{13:^This is a······························}| 261{7: }{8: 1 }in his cave. | 262{7: }{8: 2 } | 263{1:~ }|*4 264## grid 3 265| 266]] ) 267end 268else 269if foldtext then 270screen : expect ( [[ 271{10:+ }{15:1 }{13:^+-- 4 lines: This is a················}| 272{7: }{8: 1 }in his cave. | 273{7: }{8: 2 } | 274{1:~ }|*4 275| 276]] ) 277else 278screen : expect ( [[ 279{10:+ }{15:1 }{13:^This is a······························}| 280{7: }{8: 1 }in his cave. | 281{7: }{8: 2 } | 282{1:~ }|*4 283| 284]] ) 285end 286end 287end 288 289describe ( "when 'cursorline' is set" , function () 290local function cursorline_tests ( foldtext ) 291local sfx =not foldtext and ' (transparent foldtext)' or '' 292it ( 'with high-priority CursorLine' .. sfx , function () 293command ( 'hi! CursorLine guibg=NONE guifg=Red gui=NONE' ) 294test_folded_cursorline ( foldtext ) 295end ) 296 297it ( 'with low-priority CursorLine' .. sfx , function () 298command ( 'hi! CursorLine guibg=NONE guifg=NONE gui=underline' ) 299screen : add_extra_attr_ids ( { 300[ 100 ] ={ underline =true } , 301[ 101 ] ={ 302background =Screen . colors . LightGray , 303underline =true , 304foreground =Screen . colors . Blue4 , 305} , 306} ) 307test_folded_cursorline ( foldtext ) 308end ) 309end 310 311cursorline_tests ( true ) 312cursorline_tests ( false ) 313end ) 314 315it ( 'with spell' , function () 316command ( 'set spell' ) 317insert ( content1 ) 318 319feed ( 'gg' ) 320feed ( 'zf3j' ) 321if not multigrid then 322screen : expect ( [[ 323{13:^+-- 4 lines: This is a······················}| 324in his cave. | 325| 326{1:~ }|*4 327| 328]] ) 329end 330end ) 331 332it ( 'with matches' , function () 333insert ( content1 ) 334command ( 'highlight MyWord gui=bold guibg=red guifg=white' ) 335command ( "call matchadd('MyWord', '\\V' . 'test', -1)" ) 336feed ( 'gg' ) 337feed ( 'zf3j' ) 338if not multigrid then 339screen : expect ( [[ 340{13:^+-- 4 lines: This is a······················}| 341in his cave. | 342| 343{1:~ }|*4 344| 345]] ) 346end 347end ) 348 349it ( 'with multibyte fillchars' , function () 350insert ( [[ 351aa 352bb 353cc 354dd 355ee 356ff]] ) 357command ( 'set fillchars+=foldopen:▾,foldsep:│,foldclose:▸' ) 358feed_command ( '1' ) 359command ( 'set foldcolumn=2' ) 360feed ( 'zf4j' ) 361feed ( 'zf2j' ) 362feed ( 'zO' ) 363if multigrid then 364screen : expect ( [[ 365## grid 1 366[2:---------------------------------------------]|*7 367[3:---------------------------------------------]| 368## grid 2 369{7:▾▾}^aa | 370{7:││}bb | 371{7:││}cc | 372{7:││}dd | 373{7:││}ee | 374{7:│ }ff | 375{1:~ }| 376## grid 3 377:1 | 378]] ) 379else 380screen : expect ( [[ 381{7:▾▾}^aa | 382{7:││}bb | 383{7:││}cc | 384{7:││}dd | 385{7:││}ee | 386{7:│ }ff | 387{1:~ }| 388:1 | 389]] ) 390end 391 392feed_command ( 'set rightleft' ) 393if multigrid then 394screen : expect ( [[ 395## grid 1 396[2:---------------------------------------------]|*7 397[3:---------------------------------------------]| 398## grid 2 399a^a{7:▾▾}| 400bb{7:││}| 401cc{7:││}| 402dd{7:││}| 403ee{7:││}| 404ff{7: │}| 405{1: ~}| 406## grid 3 407:set rightleft | 408]] ) 409else 410screen : expect ( [[ 411a^a{7:▾▾}| 412bb{7:││}| 413cc{7:││}| 414dd{7:││}| 415ee{7:││}| 416ff{7: │}| 417{1: ~}| 418:set rightleft | 419]] ) 420end 421 422feed_command ( 'set norightleft' ) 423if multigrid then 424api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 0 , 1 ) 425screen : expect ( [[ 426## grid 1 427[2:---------------------------------------------]|*7 428[3:---------------------------------------------]| 429## grid 2 430{7:▾▸}{13:^+--- 5 lines: aa··························}| 431{7:│ }ff | 432{1:~ }|*5 433## grid 3 434:set norightleft | 435]] ) 436else 437api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 0 , 1 ) 438screen : expect ( [[ 439{7:▾▸}{13:^+--- 5 lines: aa··························}| 440{7:│ }ff | 441{1:~ }|*5 442:set norightleft | 443]] ) 444end 445 446if multigrid then 447api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 0 , 0 ) 448screen : expect ( [[ 449## grid 1 450[2:---------------------------------------------]|*7 451[3:---------------------------------------------]| 452## grid 2 453{7:▸ }{13:^+-- 6 lines: aa···························}| 454{1:~ }|*6 455## grid 3 456:set norightleft | 457]] ) 458else 459api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 0 , 0 ) 460screen : expect ( [[ 461{7:▸ }{13:^+-- 6 lines: aa···························}| 462{1:~ }|*6 463:set norightleft | 464]] ) 465end 466 467-- Add a winbar to avoid double-clicks 468command ( 'setlocal winbar=!!!!!!' ) 469if multigrid then 470api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 1 , 0 ) 471screen : expect ( [[ 472## grid 1 473[2:---------------------------------------------]|*7 474[3:---------------------------------------------]| 475## grid 2 476{5:!!!!!! }| 477{7:▾▸}{13:^+--- 5 lines: aa··························}| 478{7:│ }ff | 479{1:~ }|*4 480## grid 3 481:set norightleft | 482]] ) 483else 484api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 1 , 0 ) 485screen : expect ( [[ 486{5:!!!!!! }| 487{7:▾▸}{13:^+--- 5 lines: aa··························}| 488{7:│ }ff | 489{1:~ }|*4 490:set norightleft | 491]] ) 492end 493 494if multigrid then 495api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 1 , 1 ) 496screen : expect ( [[ 497## grid 1 498[2:---------------------------------------------]|*7 499[3:---------------------------------------------]| 500## grid 2 501{5:!!!!!! }| 502{7:▾▾}^aa | 503{7:││}bb | 504{7:││}cc | 505{7:││}dd | 506{7:││}ee | 507{7:│ }ff | 508## grid 3 509:set norightleft | 510]] ) 511else 512api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 1 , 1 ) 513screen : expect ( [[ 514{5:!!!!!! }| 515{7:▾▾}^aa | 516{7:││}bb | 517{7:││}cc | 518{7:││}dd | 519{7:││}ee | 520{7:│ }ff | 521:set norightleft | 522]] ) 523end 524end ) 525 526it ( 'with split' , function () 527insert ( [[ 528aa 529bb 530cc 531dd 532ee 533ff]] ) 534feed_command ( '2' ) 535command ( 'set foldcolumn=1' ) 536feed ( 'zf3j' ) 537feed_command ( '1' ) 538feed ( 'zf2j' ) 539feed ( 'zO' ) 540feed_command ( 'rightbelow new' ) 541insert ( [[ 542aa 543bb 544cc 545dd 546ee 547ff]] ) 548feed_command ( '2' ) 549command ( 'set foldcolumn=1' ) 550feed ( 'zf3j' ) 551feed_command ( '1' ) 552feed ( 'zf2j' ) 553if multigrid then 554api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 0 , 0 ) 555screen : expect ( [[ 556## grid 1 557[2:---------------------------------------------]|*2 558{2:[No Name] [+] }| 559[4:---------------------------------------------]|*3 560{3:[No Name] [+] }| 561[3:---------------------------------------------]| 562## grid 2 563{7:-}aa | 564{7:-}bb | 565## grid 3 566:1 | 567## grid 4 568{7:-}^aa | 569{7:+}{13:+--- 4 lines: bb···························}| 570{7:│}ff | 571]] ) 572else 573api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 3 , 0 ) 574screen : expect ( [[ 575{7:-}aa | 576{7:-}bb | 577{2:[No Name] [+] }| 578{7:-}^aa | 579{7:+}{13:+--- 4 lines: bb···························}| 580{7:│}ff | 581{3:[No Name] [+] }| 582:1 | 583]] ) 584end 585 586if multigrid then 587api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 1 , 0 ) 588screen : expect ( [[ 589## grid 1 590[2:---------------------------------------------]|*2 591{2:[No Name] [+] }| 592[4:---------------------------------------------]|*3 593{3:[No Name] [+] }| 594[3:---------------------------------------------]| 595## grid 2 596{7:-}aa | 597{7:-}bb | 598## grid 3 599:1 | 600## grid 4 601{7:-}^aa | 602{7:-}bb | 603{7:2}cc | 604]] ) 605else 606api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 4 , 0 ) 607screen : expect ( [[ 608{7:-}aa | 609{7:-}bb | 610{2:[No Name] [+] }| 611{7:-}^aa | 612{7:-}bb | 613{7:2}cc | 614{3:[No Name] [+] }| 615:1 | 616]] ) 617end 618 619if multigrid then 620api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 1 , 0 ) 621screen : expect ( [[ 622## grid 1 623[2:---------------------------------------------]|*2 624{3:[No Name] [+] }| 625[4:---------------------------------------------]|*3 626{2:[No Name] [+] }| 627[3:---------------------------------------------]| 628## grid 2 629{7:-}aa | 630{7:+}{13:^+--- 4 lines: bb···························}| 631## grid 3 632:1 | 633## grid 4 634{7:-}aa | 635{7:-}bb | 636{7:2}cc | 637]] ) 638else 639api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 1 , 0 ) 640screen : expect ( [[ 641{7:-}aa | 642{7:+}{13:^+--- 4 lines: bb···························}| 643{3:[No Name] [+] }| 644{7:-}aa | 645{7:-}bb | 646{7:2}cc | 647{2:[No Name] [+] }| 648:1 | 649]] ) 650end 651 652if multigrid then 653api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 0 , 0 ) 654screen : expect ( [[ 655## grid 1 656[2:---------------------------------------------]|*2 657{3:[No Name] [+] }| 658[4:---------------------------------------------]|*3 659{2:[No Name] [+] }| 660[3:---------------------------------------------]| 661## grid 2 662{7:+}{13:^+-- 6 lines: aa····························}| 663{1:~ }| 664## grid 3 665:1 | 666## grid 4 667{7:-}aa | 668{7:-}bb | 669{7:2}cc | 670]] ) 671else 672api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 0 , 0 ) 673screen : expect ( [[ 674{7:+}{13:^+-- 6 lines: aa····························}| 675{1:~ }| 676{3:[No Name] [+] }| 677{7:-}aa | 678{7:-}bb | 679{7:2}cc | 680{2:[No Name] [+] }| 681:1 | 682]] ) 683end 684end ) 685 686it ( 'with vsplit' , function () 687insert ( [[ 688aa 689bb 690cc 691dd 692ee 693ff]] ) 694feed_command ( '2' ) 695command ( 'set foldcolumn=1' ) 696feed ( 'zf3j' ) 697feed_command ( '1' ) 698feed ( 'zf2j' ) 699feed ( 'zO' ) 700feed_command ( 'rightbelow vnew' ) 701insert ( [[ 702aa 703bb 704cc 705dd 706ee 707ff]] ) 708feed_command ( '2' ) 709command ( 'set foldcolumn=1' ) 710feed ( 'zf3j' ) 711feed_command ( '1' ) 712feed ( 'zf2j' ) 713if multigrid then 714api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 0 , 0 ) 715screen : expect ( [[ 716## grid 1 717[2:----------------------]{2:│}[4:----------------------]|*6 718{2:[No Name] [+] }{3:[No Name] [+] }| 719[3:---------------------------------------------]| 720## grid 2 721{7:-}aa | 722{7:-}bb | 723{7:2}cc | 724{7:2}dd | 725{7:2}ee | 726{7:│}ff | 727## grid 3 728:1 | 729## grid 4 730{7:-}^aa | 731{7:+}{13:+--- 4 lines: bb····}| 732{7:│}ff | 733{1:~ }|*3 734]] ) 735else 736api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 0 , 23 ) 737screen : expect ( [[ 738{7:-}aa {2:│}{7:-}^aa | 739{7:-}bb {2:│}{7:+}{13:+--- 4 lines: bb····}| 740{7:2}cc {2:│}{7:│}ff | 741{7:2}dd {2:│}{1:~ }| 742{7:2}ee {2:│}{1:~ }| 743{7:│}ff {2:│}{1:~ }| 744{2:[No Name] [+] }{3:[No Name] [+] }| 745:1 | 746]] ) 747end 748 749if multigrid then 750api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 1 , 0 ) 751screen : expect ( [[ 752## grid 1 753[2:----------------------]{2:│}[4:----------------------]|*6 754{2:[No Name] [+] }{3:[No Name] [+] }| 755[3:---------------------------------------------]| 756## grid 2 757{7:-}aa | 758{7:-}bb | 759{7:2}cc | 760{7:2}dd | 761{7:2}ee | 762{7:│}ff | 763## grid 3 764:1 | 765## grid 4 766{7:-}^aa | 767{7:-}bb | 768{7:2}cc | 769{7:2}dd | 770{7:2}ee | 771{7:│}ff | 772]] ) 773else 774api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 1 , 23 ) 775screen : expect ( [[ 776{7:-}aa {2:│}{7:-}^aa | 777{7:-}bb {2:│}{7:-}bb | 778{7:2}cc {2:│}{7:2}cc | 779{7:2}dd {2:│}{7:2}dd | 780{7:2}ee {2:│}{7:2}ee | 781{7:│}ff {2:│}{7:│}ff | 782{2:[No Name] [+] }{3:[No Name] [+] }| 783:1 | 784]] ) 785end 786 787if multigrid then 788api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 1 , 0 ) 789screen : expect ( [[ 790## grid 1 791[2:----------------------]{2:│}[4:----------------------]|*6 792{3:[No Name] [+] }{2:[No Name] [+] }| 793[3:---------------------------------------------]| 794## grid 2 795{7:-}aa | 796{7:+}{13:^+--- 4 lines: bb····}| 797{7:│}ff | 798{1:~ }|*3 799## grid 3 800:1 | 801## grid 4 802{7:-}aa | 803{7:-}bb | 804{7:2}cc | 805{7:2}dd | 806{7:2}ee | 807{7:│}ff | 808]] ) 809else 810api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 1 , 0 ) 811screen : expect ( [[ 812{7:-}aa {2:│}{7:-}aa | 813{7:+}{13:^+--- 4 lines: bb····}{2:│}{7:-}bb | 814{7:│}ff {2:│}{7:2}cc | 815{1:~ }{2:│}{7:2}dd | 816{1:~ }{2:│}{7:2}ee | 817{1:~ }{2:│}{7:│}ff | 818{3:[No Name] [+] }{2:[No Name] [+] }| 819:1 | 820]] ) 821end 822 823if multigrid then 824api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 0 , 0 ) 825screen : expect ( [[ 826## grid 1 827[2:----------------------]{2:│}[4:----------------------]|*6 828{3:[No Name] [+] }{2:[No Name] [+] }| 829[3:---------------------------------------------]| 830## grid 2 831{7:+}{13:^+-- 6 lines: aa·····}| 832{1:~ }|*5 833## grid 3 834:1 | 835## grid 4 836{7:-}aa | 837{7:-}bb | 838{7:2}cc | 839{7:2}dd | 840{7:2}ee | 841{7:│}ff | 842]] ) 843else 844api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 0 , 0 ) 845screen : expect ( [[ 846{7:+}{13:^+-- 6 lines: aa·····}{2:│}{7:-}aa | 847{1:~ }{2:│}{7:-}bb | 848{1:~ }{2:│}{7:2}cc | 849{1:~ }{2:│}{7:2}dd | 850{1:~ }{2:│}{7:2}ee | 851{1:~ }{2:│}{7:│}ff | 852{3:[No Name] [+] }{2:[No Name] [+] }| 853:1 | 854]] ) 855end 856end ) 857 858it ( 'with tabpages' , function () 859insert ( [[ 860aa 861bb 862cc 863dd 864ee 865ff]] ) 866feed_command ( '2' ) 867command ( 'set foldcolumn=2' ) 868feed ( 'zf3j' ) 869feed_command ( '1' ) 870feed ( 'zf2j' ) 871feed ( 'zO' ) 872feed_command ( 'tab split' ) 873if multigrid then 874api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 1 , 1 ) 875screen : expect ( [[ 876## grid 1 877{24: + [No Name] }{5: + [No Name] }{2: }{24:X}| 878[4:---------------------------------------------]|*6 879[3:---------------------------------------------]| 880## grid 2 (hidden) 881{7:- }aa | 882{7:│-}bb | 883{7:││}cc | 884{7:││}dd | 885{7:││}ee | 886{7:│ }ff | 887{1:~ }| 888## grid 3 889:tab split | 890## grid 4 891{7:- }^aa | 892{7:│+}{13:+--- 4 lines: bb··························}| 893{7:│ }ff | 894{1:~ }|*3 895]] ) 896else 897api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 1 ) 898screen : expect ( [[ 899{24: + [No Name] }{5: + [No Name] }{2: }{24:X}| 900{7:- }^aa | 901{7:│+}{13:+--- 4 lines: bb··························}| 902{7:│ }ff | 903{1:~ }|*3 904:tab split | 905]] ) 906end 907 908if multigrid then 909api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 0 , 0 ) 910screen : expect ( [[ 911## grid 1 912{24: + [No Name] }{5: + [No Name] }{2: }{24:X}| 913[4:---------------------------------------------]|*6 914[3:---------------------------------------------]| 915## grid 2 (hidden) 916{7:- }aa | 917{7:│-}bb | 918{7:││}cc | 919{7:││}dd | 920{7:││}ee | 921{7:│ }ff | 922{1:~ }| 923## grid 3 924:tab split | 925## grid 4 926{7:+ }{13:^+-- 6 lines: aa···························}| 927{1:~ }|*5 928]] ) 929else 930api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 1 , 0 ) 931screen : expect ( [[ 932{24: + [No Name] }{5: + [No Name] }{2: }{24:X}| 933{7:+ }{13:^+-- 6 lines: aa···························}| 934{1:~ }|*5 935:tab split | 936]] ) 937end 938 939feed_command ( 'tabnext' ) 940if multigrid then 941api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 1 , 1 ) 942screen : expect ( [[ 943## grid 1 944{5: + [No Name] }{24: + [No Name] }{2: }{24:X}| 945[2:---------------------------------------------]|*6 946[3:---------------------------------------------]| 947## grid 2 948{7:- }^aa | 949{7:│+}{13:+--- 4 lines: bb··························}| 950{7:│ }ff | 951{1:~ }|*3 952## grid 3 953:tabnext | 954## grid 4 (hidden) 955{7:+ }{13:+-- 6 lines: aa···························}| 956{1:~ }|*5 957]] ) 958else 959api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 2 , 1 ) 960screen : expect ( [[ 961{5: + [No Name] }{24: + [No Name] }{2: }{24:X}| 962{7:- }^aa | 963{7:│+}{13:+--- 4 lines: bb··························}| 964{7:│ }ff | 965{1:~ }|*3 966:tabnext | 967]] ) 968end 969 970if multigrid then 971api . nvim_input_mouse ( 'left' , 'press' , '' , 2 , 0 , 0 ) 972screen : expect ( [[ 973## grid 1 974{5: + [No Name] }{24: + [No Name] }{2: }{24:X}| 975[2:---------------------------------------------]|*6 976[3:---------------------------------------------]| 977## grid 2 978{7:+ }{13:^+-- 6 lines: aa···························}| 979{1:~ }|*5 980## grid 3 981:tabnext | 982## grid 4 (hidden) 983{7:+ }{13:+-- 6 lines: aa···························}| 984{1:~ }|*5 985]] ) 986else 987api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 1 , 0 ) 988screen : expect ( [[ 989{5: + [No Name] }{24: + [No Name] }{2: }{24:X}| 990{7:+ }{13:^+-- 6 lines: aa···························}| 991{1:~ }|*5 992:tabnext | 993]] ) 994end 995end ) 996 997it ( 'with multibyte text' , function () 998eq ( true , api . nvim_get_option_value ( 'arabicshape' , {} )) 999insert ( [[ 1000å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة 1001möre text]] ) 1002if multigrid then 1003screen : expect ( [[ 1004## grid 1 1005[2:---------------------------------------------]|*7 1006[3:---------------------------------------------]| 1007## grid 2 1008å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ | 1009möre tex^t | 1010{1:~ }|*5 1011## grid 3 1012| 1013]] ) 1014else 1015screen : expect ( [[ 1016å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ | 1017möre tex^t | 1018{1:~ }|*5 1019| 1020]] ) 1021end 1022 1023feed ( 'vkzf' ) 1024if multigrid then 1025screen : expect ( [[ 1026## grid 1 1027[2:---------------------------------------------]|*7 1028[3:---------------------------------------------]| 1029## grid 2 1030{13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| 1031{1:~ }|*6 1032## grid 3 1033| 1034]] ) 1035else 1036screen : expect ( [[ 1037{13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| 1038{1:~ }|*6 1039| 1040]] ) 1041end 1042 1043feed_command ( 'set noarabicshape' ) 1044if multigrid then 1045screen : expect ( [[ 1046## grid 1 1047[2:---------------------------------------------]|*7 1048[3:---------------------------------------------]| 1049## grid 2 1050{13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة·················}| 1051{1:~ }|*6 1052## grid 3 1053:set noarabicshape | 1054]] ) 1055else 1056screen : expect ( [[ 1057{13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة·················}| 1058{1:~ }|*6 1059:set noarabicshape | 1060]] ) 1061end 1062 1063feed_command ( 'set number foldcolumn=2' ) 1064if multigrid then 1065screen : expect ( [[ 1066## grid 1 1067[2:---------------------------------------------]|*7 1068[3:---------------------------------------------]| 1069## grid 2 1070{7:+ }{8: 1 }{13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة···········}| 1071{1:~ }|*6 1072## grid 3 1073:set number foldcolumn=2 | 1074]] ) 1075else 1076screen : expect ( [[ 1077{7:+ }{8: 1 }{13:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة···········}| 1078{1:~ }|*6 1079:set number foldcolumn=2 | 1080]] ) 1081end 1082 1083feed_command ( 'set rightleft' ) 1084if multigrid then 1085screen : expect ( [[ 1086## grid 1 1087[2:---------------------------------------------]|*7 1088[3:---------------------------------------------]| 1089## grid 2 1090{13:···········ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}{8: 1 }{7: +}| 1091{1: ~}|*6 1092## grid 3 1093:set rightleft | 1094]] ) 1095else 1096screen : expect ( [[ 1097{13:···········ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}{8: 1 }{7: +}| 1098{1: ~}|*6 1099:set rightleft | 1100]] ) 1101end 1102 1103feed_command ( 'set nonumber foldcolumn=0' ) 1104if multigrid then 1105screen : expect ( [[ 1106## grid 1 1107[2:---------------------------------------------]|*7 1108[3:---------------------------------------------]| 1109## grid 2 1110{13:·················ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| 1111{1: ~}|*6 1112## grid 3 1113:set nonumber foldcolumn=0 | 1114]] ) 1115else 1116screen : expect ( [[ 1117{13:·················ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| 1118{1: ~}|*6 1119:set nonumber foldcolumn=0 | 1120]] ) 1121end 1122 1123feed_command ( 'set arabicshape' ) 1124if multigrid then 1125screen : expect ( [[ 1126## grid 1 1127[2:---------------------------------------------]|*7 1128[3:---------------------------------------------]| 1129## grid 2 1130{13:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| 1131{1: ~}|*6 1132## grid 3 1133:set arabicshape | 1134]] ) 1135else 1136screen : expect ( [[ 1137{13:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| 1138{1: ~}|*6 1139:set arabicshape | 1140]] ) 1141end 1142 1143feed ( 'zo' ) 1144if multigrid then 1145screen : expect ( [[ 1146## grid 1 1147[2:---------------------------------------------]|*7 1148[3:---------------------------------------------]| 1149## grid 2 1150ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| 1151txet eröm| 1152{1: ~}|*5 1153## grid 3 1154:set arabicshape | 1155]] ) 1156else 1157screen : expect ( [[ 1158ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| 1159txet eröm| 1160{1: ~}|*5 1161:set arabicshape | 1162]] ) 1163end 1164 1165feed_command ( 'set noarabicshape' ) 1166if multigrid then 1167screen : expect ( [[ 1168## grid 1 1169[2:---------------------------------------------]|*7 1170[3:---------------------------------------------]| 1171## grid 2 1172ةيَّبِرَعَ^لا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| 1173txet eröm| 1174{1: ~}|*5 1175## grid 3 1176:set noarabicshape | 1177]] ) 1178else 1179screen : expect ( [[ 1180ةيَّبِرَعَ^لا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| 1181txet eröm| 1182{1: ~}|*5 1183:set noarabicshape | 1184]] ) 1185end 1186end ) 1187 1188it ( 'foldcolumn autoresize' , function () 1189fn . setline ( 1 , 'line 1' ) 1190fn . setline ( 2 , 'line 2' ) 1191fn . setline ( 3 , 'line 3' ) 1192fn . setline ( 4 , 'line 4' ) 1193 1194feed ( 'zfj' ) 1195command ( 'set foldcolumn=0' ) 1196if multigrid then 1197screen : expect ( [[ 1198## grid 1 1199[2:---------------------------------------------]|*7 1200[3:---------------------------------------------]| 1201## grid 2 1202{13:^+-- 2 lines: line 1·························}| 1203line 3 | 1204line 4 | 1205{1:~ }|*4 1206## grid 3 1207| 1208]] ) 1209else 1210screen : expect ( [[ 1211{13:^+-- 2 lines: line 1·························}| 1212line 3 | 1213line 4 | 1214{1:~ }|*4 1215| 1216]] ) 1217end 1218-- should adapt to the current nesting of folds (e.g., 1) 1219command ( 'set foldcolumn=auto:1' ) 1220if multigrid then 1221screen : expect ( [[ 1222## grid 1 1223[2:---------------------------------------------]|*7 1224[3:---------------------------------------------]| 1225## grid 2 1226{7:+}{13:^+-- 2 lines: line 1························}| 1227{7: }line 3 | 1228{7: }line 4 | 1229{1:~ }|*4 1230## grid 3 1231| 1232]] ) 1233else 1234screen : expect ( [[ 1235{7:+}{13:^+-- 2 lines: line 1························}| 1236{7: }line 3 | 1237{7: }line 4 | 1238{1:~ }|*4 1239| 1240]] ) 1241end 1242command ( 'set foldcolumn=auto' ) 1243if multigrid then 1244screen : expect { 1245grid =[[ 1246## grid 1 1247[2:---------------------------------------------]|*7 1248[3:---------------------------------------------]| 1249## grid 2 1250{7:+}{13:^+-- 2 lines: line 1························}| 1251{7: }line 3 | 1252{7: }line 4 | 1253{1:~ }|*4 1254## grid 3 1255| 1256]] , 1257unchanged =true , 1258} 1259else 1260screen : expect { 1261grid =[[ 1262{7:+}{13:^+-- 2 lines: line 1························}| 1263{7: }line 3 | 1264{7: }line 4 | 1265{1:~ }|*4 1266| 1267]] , 1268unchanged =true , 1269} 1270end 1271-- fdc should not change with a new fold as the maximum is 1 1272feed ( 'zf3j' ) 1273 1274if multigrid then 1275screen : expect ( [[ 1276## grid 1 1277[2:---------------------------------------------]|*7 1278[3:---------------------------------------------]| 1279## grid 2 1280{7:+}{13:^+-- 4 lines: line 1························}| 1281{1:~ }|*6 1282## grid 3 1283| 1284]] ) 1285else 1286screen : expect ( [[ 1287{7:+}{13:^+-- 4 lines: line 1························}| 1288{1:~ }|*6 1289| 1290]] ) 1291end 1292 1293command ( 'set foldcolumn=auto:1' ) 1294if multigrid then 1295screen : expect_unchanged () 1296end 1297 1298-- relax the maximum fdc thus fdc should expand to 1299-- accommodate the current number of folds 1300command ( 'set foldcolumn=auto:4' ) 1301if multigrid then 1302screen : expect ( [[ 1303## grid 1 1304[2:---------------------------------------------]|*7 1305[3:---------------------------------------------]| 1306## grid 2 1307{7:+ }{13:^+-- 4 lines: line 1·······················}| 1308{1:~ }|*6 1309## grid 3 1310| 1311]] ) 1312else 1313screen : expect ( [[ 1314{7:+ }{13:^+-- 4 lines: line 1·······················}| 1315{1:~ }|*6 1316| 1317]] ) 1318end 1319end ) 1320 1321it ( 'no crash when foldtext is longer than columns #12988' , function () 1322exec ( [[ 1323function! MyFoldText() abort 1324return repeat('-', &columns + 100) 1325endfunction 1326]] ) 1327command ( 'set foldtext=MyFoldText()' ) 1328feed ( 'i<cr><esc>' ) 1329feed ( 'vkzf' ) 1330if multigrid then 1331screen : expect ( [[ 1332## grid 1 1333[2:---------------------------------------------]|*7 1334[3:---------------------------------------------]| 1335## grid 2 1336{13:^---------------------------------------------}| 1337{1:~ }|*6 1338## grid 3 1339| 1340]] ) 1341else 1342screen : expect ( [[ 1343{13:^---------------------------------------------}| 1344{1:~ }|*6 1345| 1346]] ) 1347end 1348assert_alive () 1349end ) 1350 1351it ( 'fold text is shown when text has been scrolled to the right #19123' , function () 1352insert ( content1 ) 1353command ( 'set number nowrap' ) 1354command ( '3,4fold' ) 1355feed ( 'gg' ) 1356if multigrid then 1357screen : expect ( [[ 1358## grid 1 1359[2:---------------------------------------------]|*7 1360[3:---------------------------------------------]| 1361## grid 2 1362{8: 1 }^This is a | 1363{8: 2 }valid English | 1364{8: 3 }{13:+-- 2 lines: sentence composed by·······}| 1365{8: 5 }in his cave. | 1366{8: 6 } | 1367{1:~ }|*2 1368## grid 3 1369| 1370]] ) 1371else 1372screen : expect ( [[ 1373{8: 1 }^This is a | 1374{8: 2 }valid English | 1375{8: 3 }{13:+-- 2 lines: sentence composed by·······}| 1376{8: 5 }in his cave. | 1377{8: 6 } | 1378{1:~ }|*2 1379| 1380]] ) 1381end 1382 1383feed ( 'zl' ) 1384if multigrid then 1385screen : expect ( [[ 1386## grid 1 1387[2:---------------------------------------------]|*7 1388[3:---------------------------------------------]| 1389## grid 2 1390{8: 1 }^his is a | 1391{8: 2 }alid English | 1392{8: 3 }{13:+-- 2 lines: sentence composed by·······}| 1393{8: 5 }n his cave. | 1394{8: 6 } | 1395{1:~ }|*2 1396## grid 3 1397| 1398]] ) 1399else 1400screen : expect ( [[ 1401{8: 1 }^his is a | 1402{8: 2 }alid English | 1403{8: 3 }{13:+-- 2 lines: sentence composed by·······}| 1404{8: 5 }n his cave. | 1405{8: 6 } | 1406{1:~ }|*2 1407| 1408]] ) 1409end 1410 1411eq ( { 0 , 1 , 2 , 0 , 2 } , fn . getcurpos ()) 1412api . nvim_input_mouse ( 'left' , 'press' , '' , multigrid and 2 or 0 , 2 , 4 ) 1413eq ( { 0 , 3 , 2 , 0 , 2 } , fn . getcurpos ()) 1414feed ( '2k' ) 1415eq ( { 0 , 1 , 2 , 0 , 2 } , fn . getcurpos ()) 1416 1417api . nvim_set_option_value ( 'foldtext' , "'αβγ'" , { win =0 } ) 1418-- No crash or memory leak when scrolling beyond end of folded line #33931 1419fn . append ( '$' , ( '!' ): rep ( 100 )) 1420feed ( 'G$' ) 1421if multigrid then 1422screen : expect ( [[ 1423## grid 1 1424[2:---------------------------------------------]|*7 1425[3:---------------------------------------------]| 1426## grid 2 1427{8: 1 } | 1428{8: 2 } | 1429{8: 3 }{13:αβγ······································}| 1430{8: 5 } | 1431{8: 6 } | 1432{8: 7 }!!!!!!!!!!!!!!!!!!!!^! | 1433{1:~ }| 1434## grid 3 1435| 1436]] ) 1437else 1438screen : expect ( [[ 1439{8: 1 } | 1440{8: 2 } | 1441{8: 3 }{13:αβγ······································}| 1442{8: 5 } | 1443{8: 6 } | 1444{8: 7 }!!!!!!!!!!!!!!!!!!!!^! | 1445{1:~ }| 1446| 1447]] ) 1448end 1449end ) 1450 1451it ( 'fold attached virtual lines are drawn and scrolled correctly #21837' , function () 1452fn . setline ( 1 , 'line 1' ) 1453fn . setline ( 2 , 'line 2' ) 1454fn . setline ( 3 , 'line 3' ) 1455fn . setline ( 4 , 'line 4' ) 1456feed ( 'zfj' ) 1457local ns =api . nvim_create_namespace ( 'ns' ) 1458api . nvim_buf_set_extmark ( 14590 , 1460ns , 14610 , 14620 , 1463{ virt_lines_above =true , virt_lines ={ { { 'virt_line above line 1' , '' } } } } 1464) 1465api . nvim_buf_set_extmark ( 14660 , 1467ns , 14681 , 14690 , 1470{ virt_lines ={ { { 'virt_line below line 2' , '' } } } } 1471) 1472api . nvim_buf_set_extmark ( 14730 , 1474ns , 14752 , 14760 , 1477{ virt_lines_above =true , virt_lines ={ { { 'virt_line above line 3' , '' } } } } 1478) 1479api . nvim_buf_set_extmark ( 14800 , 1481ns , 14823 , 14830 , 1484{ virt_lines ={ { { 'virt_line below line 4' , '' } } } } 1485) 1486if multigrid then 1487screen : expect { 1488grid =[[ 1489## grid 1 1490[2:---------------------------------------------]|*7 1491[3:---------------------------------------------]| 1492## grid 2 1493{13:^+-- 2 lines: line 1·························}| 1494virt_line above line 3 | 1495line 3 | 1496line 4 | 1497virt_line below line 4 | 1498{1:~ }|*2 1499## grid 3 1500| 1501]] , 1502win_viewport ={ 1503[ 2 ] ={ 1504win =1000 , 1505topline =0 , 1506botline =5 , 1507curline =0 , 1508curcol =0 , 1509linecount =4 , 1510sum_scroll_delta =0 , 1511} , 1512} , 1513} 1514else 1515screen : expect ( [[ 1516{13:^+-- 2 lines: line 1·························}| 1517virt_line above line 3 | 1518line 3 | 1519line 4 | 1520virt_line below line 4 | 1521{1:~ }|*2 1522| 1523]] ) 1524end 1525 1526feed ( 'jzfj' ) 1527if multigrid then 1528screen : expect { 1529grid =[[ 1530## grid 1 1531[2:---------------------------------------------]|*7 1532[3:---------------------------------------------]| 1533## grid 2 1534{13:+-- 2 lines: line 1·························}| 1535{13:^+-- 2 lines: line 3·························}| 1536{1:~ }|*5 1537## grid 3 1538| 1539]] , 1540win_viewport ={ 1541[ 2 ] ={ 1542win =1000 , 1543topline =0 , 1544botline =5 , 1545curline =2 , 1546curcol =0 , 1547linecount =4 , 1548sum_scroll_delta =0 , 1549} , 1550} , 1551} 1552else 1553screen : expect ( [[ 1554{13:+-- 2 lines: line 1·························}| 1555{13:^+-- 2 lines: line 3·························}| 1556{1:~ }|*5 1557| 1558]] ) 1559end 1560 1561feed ( 'kzo<C-Y>' ) 1562fn . setline ( 5 , 'line 5' ) 1563if multigrid then 1564screen : expect { 1565grid =[[ 1566## grid 1 1567[2:---------------------------------------------]|*7 1568[3:---------------------------------------------]| 1569## grid 2 1570virt_line above line 1 | 1571^line 1 | 1572line 2 | 1573virt_line below line 2 | 1574{13:+-- 2 lines: line 3·························}| 1575line 5 | 1576{1:~ }| 1577## grid 3 1578| 1579]] , 1580win_viewport ={ 1581[ 2 ] ={ 1582win =1000 , 1583topline =0 , 1584botline =6 , 1585curline =0 , 1586curcol =0 , 1587linecount =5 , 1588sum_scroll_delta =- 1 , 1589} , 1590} , 1591} 1592else 1593screen : expect ( [[ 1594virt_line above line 1 | 1595^line 1 | 1596line 2 | 1597virt_line below line 2 | 1598{13:+-- 2 lines: line 3·························}| 1599line 5 | 1600{1:~ }| 1601| 1602]] ) 1603end 1604 1605api . nvim_input_mouse ( 'left' , 'press' , '' , multigrid and 2 or 0 , 4 , 0 ) 1606eq ( { 1607screencol =1 , 1608screenrow =5 , 1609winid =1000 , 1610wincol =1 , 1611winrow =5 , 1612line =3 , 1613column =1 , 1614coladd =0 , 1615} , fn . getmousepos ()) 1616 1617api . nvim_buf_set_extmark ( 16180 , 1619ns , 16201 , 16210 , 1622{ virt_lines ={ { { 'more virt_line below line 2' , '' } } } } 1623) 1624feed ( 'G<C-E>' ) 1625if multigrid then 1626screen : expect { 1627grid =[[ 1628## grid 1 1629[2:---------------------------------------------]|*7 1630[3:---------------------------------------------]| 1631## grid 2 1632line 1 | 1633line 2 | 1634virt_line below line 2 | 1635more virt_line below line 2 | 1636{13:+-- 2 lines: line 3·························}| 1637^line 5 | 1638{1:~ }| 1639## grid 3 1640| 1641]] , 1642win_viewport ={ 1643[ 2 ] ={ 1644win =1000 , 1645topline =0 , 1646botline =6 , 1647curline =4 , 1648curcol =0 , 1649linecount =5 , 1650sum_scroll_delta =0 , 1651} , 1652} , 1653} 1654else 1655screen : expect ( [[ 1656line 1 | 1657line 2 | 1658virt_line below line 2 | 1659more virt_line below line 2 | 1660{13:+-- 2 lines: line 3·························}| 1661^line 5 | 1662{1:~ }| 1663| 1664]] ) 1665end 1666 1667feed ( '<C-E>' ) 1668if multigrid then 1669screen : expect { 1670grid =[[ 1671## grid 1 1672[2:---------------------------------------------]|*7 1673[3:---------------------------------------------]| 1674## grid 2 1675line 2 | 1676virt_line below line 2 | 1677more virt_line below line 2 | 1678{13:+-- 2 lines: line 3·························}| 1679^line 5 | 1680{1:~ }|*2 1681## grid 3 1682| 1683]] , 1684win_viewport ={ 1685[ 2 ] ={ 1686win =1000 , 1687topline =1 , 1688botline =6 , 1689curline =4 , 1690curcol =0 , 1691linecount =5 , 1692sum_scroll_delta =1 , 1693} , 1694} , 1695} 1696else 1697screen : expect ( [[ 1698line 2 | 1699virt_line below line 2 | 1700more virt_line below line 2 | 1701{13:+-- 2 lines: line 3·························}| 1702^line 5 | 1703{1:~ }|*2 1704| 1705]] ) 1706end 1707 1708feed ( '<C-E>' ) 1709if multigrid then 1710screen : expect { 1711grid =[[ 1712## grid 1 1713[2:---------------------------------------------]|*7 1714[3:---------------------------------------------]| 1715## grid 2 1716virt_line below line 2 | 1717more virt_line below line 2 | 1718{13:+-- 2 lines: line 3·························}| 1719^line 5 | 1720{1:~ }|*3 1721## grid 3 1722| 1723]] , 1724win_viewport ={ 1725[ 2 ] ={ 1726win =1000 , 1727topline =2 , 1728botline =6 , 1729curline =4 , 1730curcol =0 , 1731linecount =5 , 1732sum_scroll_delta =2 , 1733} , 1734} , 1735} 1736else 1737screen : expect ( [[ 1738virt_line below line 2 | 1739more virt_line below line 2 | 1740{13:+-- 2 lines: line 3·························}| 1741^line 5 | 1742{1:~ }|*3 1743| 1744]] ) 1745end 1746 1747feed ( '<C-E>' ) 1748if multigrid then 1749screen : expect { 1750grid =[[ 1751## grid 1 1752[2:---------------------------------------------]|*7 1753[3:---------------------------------------------]| 1754## grid 2 1755more virt_line below line 2 | 1756{13:+-- 2 lines: line 3·························}| 1757^line 5 | 1758{1:~ }|*4 1759## grid 3 1760| 1761]] , 1762win_viewport ={ 1763[ 2 ] ={ 1764win =1000 , 1765topline =2 , 1766botline =6 , 1767curline =4 , 1768curcol =0 , 1769linecount =5 , 1770sum_scroll_delta =3 , 1771} , 1772} , 1773} 1774else 1775screen : expect ( [[ 1776more virt_line below line 2 | 1777{13:+-- 2 lines: line 3·························}| 1778^line 5 | 1779{1:~ }|*4 1780| 1781]] ) 1782end 1783 1784feed ( '<C-E>' ) 1785if multigrid then 1786screen : expect { 1787grid =[[ 1788## grid 1 1789[2:---------------------------------------------]|*7 1790[3:---------------------------------------------]| 1791## grid 2 1792{13:+-- 2 lines: line 3·························}| 1793^line 5 | 1794{1:~ }|*5 1795## grid 3 1796| 1797]] , 1798win_viewport ={ 1799[ 2 ] ={ 1800win =1000 , 1801topline =2 , 1802botline =6 , 1803curline =4 , 1804curcol =0 , 1805linecount =5 , 1806sum_scroll_delta =4 , 1807} , 1808} , 1809} 1810else 1811screen : expect ( [[ 1812{13:+-- 2 lines: line 3·························}| 1813^line 5 | 1814{1:~ }|*5 1815| 1816]] ) 1817end 1818 1819feed ( '<C-E>' ) 1820if multigrid then 1821screen : expect { 1822grid =[[ 1823## grid 1 1824[2:---------------------------------------------]|*7 1825[3:---------------------------------------------]| 1826## grid 2 1827^line 5 | 1828{1:~ }|*6 1829## grid 3 1830| 1831]] , 1832win_viewport ={ 1833[ 2 ] ={ 1834win =1000 , 1835topline =4 , 1836botline =6 , 1837curline =4 , 1838curcol =0 , 1839linecount =5 , 1840sum_scroll_delta =5 , 1841} , 1842} , 1843} 1844else 1845screen : expect ( [[ 1846^line 5 | 1847{1:~ }|*6 1848| 1849]] ) 1850end 1851 1852feed ( '3<C-Y>' ) 1853if multigrid then 1854screen : expect { 1855grid =[[ 1856## grid 1 1857[2:---------------------------------------------]|*7 1858[3:---------------------------------------------]| 1859## grid 2 1860virt_line below line 2 | 1861more virt_line below line 2 | 1862{13:+-- 2 lines: line 3·························}| 1863^line 5 | 1864{1:~ }|*3 1865## grid 3 1866| 1867]] , 1868win_viewport ={ 1869[ 2 ] ={ 1870win =1000 , 1871topline =2 , 1872botline =6 , 1873curline =4 , 1874curcol =0 , 1875linecount =5 , 1876sum_scroll_delta =2 , 1877} , 1878} , 1879} 1880else 1881screen : expect ( [[ 1882virt_line below line 2 | 1883more virt_line below line 2 | 1884{13:+-- 2 lines: line 3·························}| 1885^line 5 | 1886{1:~ }|*3 1887| 1888]] ) 1889end 1890 1891api . nvim_input_mouse ( 'left' , 'press' , '3' , multigrid and 2 or 0 , 3 , 0 ) 1892if multigrid then 1893screen : expect { 1894grid =[[ 1895## grid 1 1896[2:---------------------------------------------]|*7 1897[3:---------------------------------------------]| 1898## grid 2 1899virt_line below line 2 | 1900more virt_line below line 2 | 1901{13:+-- 2 lines: line 3·························}| 1902{17:^line 5} | 1903{1:~ }|*3 1904## grid 3 1905{5:-- VISUAL LINE --} | 1906]] , 1907win_viewport ={ 1908[ 2 ] ={ 1909win =1000 , 1910topline =2 , 1911botline =6 , 1912curline =4 , 1913curcol =0 , 1914linecount =5 , 1915sum_scroll_delta =2 , 1916} , 1917} , 1918} 1919else 1920screen : expect ( [[ 1921virt_line below line 2 | 1922more virt_line below line 2 | 1923{13:+-- 2 lines: line 3·························}| 1924{17:^line 5} | 1925{1:~ }|*3 1926{5:-- VISUAL LINE --} | 1927]] ) 1928end 1929 1930api . nvim_input_mouse ( 'left' , 'drag' , '3' , multigrid and 2 or 0 , 7 , 0 ) 1931if multigrid then 1932screen : expect { 1933grid =[[ 1934## grid 1 1935[2:---------------------------------------------]|*7 1936[3:---------------------------------------------]| 1937## grid 2 1938more virt_line below line 2 | 1939{13:+-- 2 lines: line 3·························}| 1940{17:^line 5} | 1941{1:~ }|*4 1942## grid 3 1943{5:-- VISUAL LINE --} | 1944]] , 1945win_viewport ={ 1946[ 2 ] ={ 1947win =1000 , 1948topline =2 , 1949botline =6 , 1950curline =4 , 1951curcol =0 , 1952linecount =5 , 1953sum_scroll_delta =3 , 1954} , 1955} , 1956} 1957else 1958screen : expect ( [[ 1959more virt_line below line 2 | 1960{13:+-- 2 lines: line 3·························}| 1961{17:^line 5} | 1962{1:~ }|*4 1963{5:-- VISUAL LINE --} | 1964]] ) 1965end 1966 1967api . nvim_input_mouse ( 'left' , 'drag' , '3' , multigrid and 2 or 0 , 7 , 5 ) 1968if multigrid then 1969screen : expect { 1970grid =[[ 1971## grid 1 1972[2:---------------------------------------------]|*7 1973[3:---------------------------------------------]| 1974## grid 2 1975{13:+-- 2 lines: line 3·························}| 1976{17:line ^5} | 1977{1:~ }|*5 1978## grid 3 1979{5:-- VISUAL LINE --} | 1980]] , 1981win_viewport ={ 1982[ 2 ] ={ 1983win =1000 , 1984topline =2 , 1985botline =6 , 1986curline =4 , 1987curcol =5 , 1988linecount =5 , 1989sum_scroll_delta =4 , 1990} , 1991} , 1992} 1993else 1994screen : expect ( [[ 1995{13:+-- 2 lines: line 3·························}| 1996{17:line ^5} | 1997{1:~ }|*5 1998{5:-- VISUAL LINE --} | 1999]] ) 2000end 2001 2002feed ( '<Esc>gg' ) 2003command ( 'botright 1split | wincmd w' ) 2004if multigrid then 2005screen : expect { 2006grid =[[ 2007## grid 1 2008[2:---------------------------------------------]|*4 2009{3:[No Name] [+] }| 2010[4:---------------------------------------------]| 2011{2:[No Name] [+] }| 2012[3:---------------------------------------------]| 2013## grid 2 2014^line 1 | 2015line 2 | 2016virt_line below line 2 | 2017more virt_line below line 2 | 2018## grid 3 2019| 2020## grid 4 2021line 1 | 2022]] , 2023win_viewport ={ 2024[ 2 ] ={ 2025win =1000 , 2026topline =0 , 2027botline =3 , 2028curline =0 , 2029curcol =0 , 2030linecount =5 , 2031sum_scroll_delta =0 , 2032} , 2033[ 4 ] ={ 2034win =1001 , 2035topline =0 , 2036botline =2 , 2037curline =0 , 2038curcol =0 , 2039linecount =5 , 2040sum_scroll_delta =0 , 2041} , 2042} , 2043} 2044else 2045screen : expect ( [[ 2046^line 1 | 2047line 2 | 2048virt_line below line 2 | 2049more virt_line below line 2 | 2050{3:[No Name] [+] }| 2051line 1 | 2052{2:[No Name] [+] }| 2053| 2054]] ) 2055end 2056 2057feed ( '<C-Y>' ) 2058if multigrid then 2059screen : expect { 2060grid =[[ 2061## grid 1 2062[2:---------------------------------------------]|*4 2063{3:[No Name] [+] }| 2064[4:---------------------------------------------]| 2065{2:[No Name] [+] }| 2066[3:---------------------------------------------]| 2067## grid 2 2068virt_line above line 1 | 2069^line 1 | 2070line 2 | 2071virt_line below line 2 | 2072## grid 3 2073| 2074## grid 4 2075line 1 | 2076]] , 2077win_viewport ={ 2078[ 2 ] ={ 2079win =1000 , 2080topline =0 , 2081botline =3 , 2082curline =0 , 2083curcol =0 , 2084linecount =5 , 2085sum_scroll_delta =- 1 , 2086} , 2087[ 4 ] ={ 2088win =1001 , 2089topline =0 , 2090botline =2 , 2091curline =0 , 2092curcol =0 , 2093linecount =5 , 2094sum_scroll_delta =0 , 2095} , 2096} , 2097} 2098else 2099screen : expect ( [[ 2100virt_line above line 1 | 2101^line 1 | 2102line 2 | 2103virt_line below line 2 | 2104{3:[No Name] [+] }| 2105line 1 | 2106{2:[No Name] [+] }| 2107| 2108]] ) 2109end 2110end ) 2111 2112it ( 'virt_lines above line where fold begins do not duplicate foldcolumn' , function () 2113fn . setline ( 1 , 'line 1' ) 2114fn . setline ( 2 , 'line 2' ) 2115fn . setline ( 3 , 'line 3' ) 2116fn . setline ( 4 , 'line 4' ) 2117 2118local ns =api . nvim_create_namespace ( 'ns' ) 2119api . nvim_buf_set_extmark ( 21200 , 2121ns , 21221 , 21230 , 2124{ virt_lines_above =true , virt_lines ={ { { 'above line 2' } } } } 2125) 2126api . nvim_buf_set_extmark ( 0 , ns , 2 , 0 , { virt_lines ={ { { 'below line 3' } } } } ) 2127 2128command ( 'set foldcolumn=1' ) 2129feed ( 'jzfl' ) 2130feed ( '2jzfl' ) 2131if multigrid then 2132screen : expect ( [[ 2133## grid 1 2134[2:---------------------------------------------]|*7 2135[3:---------------------------------------------]| 2136## grid 2 2137{7: }line 1 | 2138{7: }above line 2 | 2139{7:-}line 2 | 2140{7: }line 3 | 2141{7: }below line 3 | 2142{7:-}^line 4 | 2143{1:~ }| 2144## grid 3 2145| 2146]] ) 2147else 2148screen : expect ( [[ 2149{7: }line 1 | 2150{7: }above line 2 | 2151{7:-}line 2 | 2152{7: }line 3 | 2153{7: }below line 3 | 2154{7:-}^line 4 | 2155{1:~ }| 2156| 2157]] ) 2158end 2159 2160-- `foldcolumn` in `statuscolumn` should be identical 2161command ( 'set statuscolumn=%C' ) 2162screen : expect_unchanged () 2163end ) 2164 2165it ( 'foldcolumn is not interrupted when virt_lines are inside a fold' , function () 2166fn . setline ( 1 , 'line 1' ) 2167fn . setline ( 2 , 'line 2' ) 2168fn . setline ( 3 , 'line 3' ) 2169fn . setline ( 4 , 'line 4' ) 2170 2171local ns =api . nvim_create_namespace ( 'ns' ) 2172api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { virt_lines ={ { { 'below line 2' , '' } } } } ) 2173api . nvim_buf_set_extmark ( 21740 , 2175ns , 21762 , 21770 , 2178{ virt_lines_above =true , virt_lines ={ { { 'above line 3' , '' } } } } 2179) 2180 2181command ( 'set foldcolumn=1' ) 2182feed ( 'zf2j' ) 2183feed ( 'zo' ) 2184if multigrid then 2185screen : expect ( [[ 2186## grid 1 2187[2:---------------------------------------------]|*7 2188[3:---------------------------------------------]| 2189## grid 2 2190{7:-}^line 1 | 2191{7:│}line 2 | 2192{7:│}below line 2 | 2193{7:│}above line 3 | 2194{7:│}line 3 | 2195{7: }line 4 | 2196{1:~ }| 2197## grid 3 2198| 2199]] ) 2200else 2201screen : expect ( [[ 2202{7:-}^line 1 | 2203{7:│}line 2 | 2204{7:│}below line 2 | 2205{7:│}above line 3 | 2206{7:│}line 3 | 2207{7: }line 4 | 2208{1:~ }| 2209| 2210]] ) 2211end 2212 2213command ( 'set statuscolumn=%C' ) 2214screen : expect_unchanged () 2215end ) 2216 2217it ( 'foldcolumn for a virt_line above a nested fold shows correct fold level' , function () 2218fn . setline ( 1 , 'line 1' ) 2219fn . setline ( 2 , 'line 2' ) 2220fn . setline ( 3 , 'line 3' ) 2221fn . setline ( 4 , 'line 4' ) 2222 2223local ns =api . nvim_create_namespace ( 'ns' ) 2224api . nvim_buf_set_extmark ( 0 , ns , 1 , 0 , { virt_lines ={ { { 'below line 2' , '' } } } } ) 2225api . nvim_buf_set_extmark ( 22260 , 2227ns , 22282 , 22290 , 2230{ virt_lines_above =true , virt_lines ={ { { 'above line 3' , '' } } } } 2231) 2232 2233command ( '1,4fold | 1,4foldopen' ) 2234command ( '3,4fold | 3,4foldopen ' ) 2235command ( 'set foldcolumn=1' ) 2236if multigrid then 2237screen : expect ( [[ 2238## grid 1 2239[2:---------------------------------------------]|*7 2240[3:---------------------------------------------]| 2241## grid 2 2242{7:-}^line 1 | 2243{7:│}line 2 | 2244{7:│}below line 2 | 2245{7:│}above line 3 | 2246{7:-}line 3 | 2247{7:2}line 4 | 2248{1:~ }| 2249## grid 3 2250| 2251]] ) 2252else 2253screen : expect ( [[ 2254{7:-}^line 1 | 2255{7:│}line 2 | 2256{7:│}below line 2 | 2257{7:│}above line 3 | 2258{7:-}line 3 | 2259{7:2}line 4 | 2260{1:~ }| 2261| 2262]] ) 2263end 2264 2265command ( 'set statuscolumn=%C' ) 2266screen : expect_unchanged () 2267command ( 'set statuscolumn=' ) 2268 2269command ( 'set foldcolumn=2' ) 2270if multigrid then 2271screen : expect ( [[ 2272## grid 1 2273[2:---------------------------------------------]|*7 2274[3:---------------------------------------------]| 2275## grid 2 2276{7:- }^line 1 | 2277{7:│ }line 2 | 2278{7:│ }below line 2 | 2279{7:│ }above line 3 | 2280{7:│-}line 3 | 2281{7:││}line 4 | 2282{1:~ }| 2283## grid 3 2284| 2285]] ) 2286else 2287screen : expect ( [[ 2288{7:- }^line 1 | 2289{7:│ }line 2 | 2290{7:│ }below line 2 | 2291{7:│ }above line 3 | 2292{7:│-}line 3 | 2293{7:││}line 4 | 2294{1:~ }| 2295| 2296]] ) 2297end 2298 2299command ( 'set statuscolumn=%C' ) 2300screen : expect_unchanged () 2301command ( 'set statuscolumn=' ) 2302 2303command ( '2,4fold | 2,4foldopen' ) 2304if multigrid then 2305screen : expect ( [[ 2306## grid 1 2307[2:---------------------------------------------]|*7 2308[3:---------------------------------------------]| 2309## grid 2 2310{7:- }^line 1 | 2311{7:│-}line 2 | 2312{7:││}below line 2 | 2313{7:││}above line 3 | 2314{7:2-}line 3 | 2315{7:23}line 4 | 2316{1:~ }| 2317## grid 3 2318| 2319]] ) 2320else 2321screen : expect ( [[ 2322{7:- }^line 1 | 2323{7:│-}line 2 | 2324{7:││}below line 2 | 2325{7:││}above line 3 | 2326{7:2-}line 3 | 2327{7:23}line 4 | 2328{1:~ }| 2329| 2330]] ) 2331end 2332 2333command ( 'set statuscolumn=%C' ) 2334screen : expect_unchanged () 2335end ) 2336 2337it ( 'Folded and Visual highlights are combined #19691' , function () 2338command ( 'hi! Visual guifg=NONE guibg=Red' ) 2339insert ( [[ 2340" foofoofoofoofoofoo 2341" 口 {{{1 2342set nocp 2343" }}}1 2344" barbarbarbarbarbar 2345" 口 {{{1 2346set foldmethod=marker 2347" }}}1 2348" bazbazbazbazbazbaz]] ) 2349feed ( 'gg' ) 2350command ( 'source' ) 2351feed ( '<C-V>G15l' ) 2352if multigrid then 2353screen : expect ( [[ 2354## grid 1 2355[2:---------------------------------------------]|*7 2356[3:---------------------------------------------]| 2357## grid 2 2358{30:" foofoofoofoofo}ofoo | 2359{103:+-- 3 lines: " }{13:口···························}| 2360{30:" barbarbarbarba}rbar | 2361{103:+-- 3 lines: " }{13:口···························}| 2362{30:" bazbazbazbazb^a}zbaz | 2363{1:~ }|*2 2364## grid 3 2365{5:-- VISUAL BLOCK --} | 2366]] ) 2367else 2368screen : expect ( [[ 2369{30:" foofoofoofoofo}ofoo | 2370{103:+-- 3 lines: " }{13:口···························}| 2371{30:" barbarbarbarba}rbar | 2372{103:+-- 3 lines: " }{13:口···························}| 2373{30:" bazbazbazbazb^a}zbaz | 2374{1:~ }|*2 2375{5:-- VISUAL BLOCK --} | 2376]] ) 2377end 2378 2379feed ( 'l' ) 2380if multigrid then 2381screen : expect ( [[ 2382## grid 1 2383[2:---------------------------------------------]|*7 2384[3:---------------------------------------------]| 2385## grid 2 2386{30:" foofoofoofoofoo}foo | 2387{103:+-- 3 lines: " 口}{13:···························}| 2388{30:" barbarbarbarbar}bar | 2389{103:+-- 3 lines: " 口}{13:···························}| 2390{30:" bazbazbazbazba^z}baz | 2391{1:~ }|*2 2392## grid 3 2393{5:-- VISUAL BLOCK --} | 2394]] ) 2395else 2396screen : expect ( [[ 2397{30:" foofoofoofoofoo}foo | 2398{103:+-- 3 lines: " 口}{13:···························}| 2399{30:" barbarbarbarbar}bar | 2400{103:+-- 3 lines: " 口}{13:···························}| 2401{30:" bazbazbazbazba^z}baz | 2402{1:~ }|*2 2403{5:-- VISUAL BLOCK --} | 2404]] ) 2405end 2406 2407feed ( 'l' ) 2408if multigrid then 2409screen : expect ( [[ 2410## grid 1 2411[2:---------------------------------------------]|*7 2412[3:---------------------------------------------]| 2413## grid 2 2414{30:" foofoofoofoofoof}oo | 2415{103:+-- 3 lines: " 口}{13:···························}| 2416{30:" barbarbarbarbarb}ar | 2417{103:+-- 3 lines: " 口}{13:···························}| 2418{30:" bazbazbazbazbaz^b}az | 2419{1:~ }|*2 2420## grid 3 2421{5:-- VISUAL BLOCK --} | 2422]] ) 2423else 2424screen : expect ( [[ 2425{30:" foofoofoofoofoof}oo | 2426{103:+-- 3 lines: " 口}{13:···························}| 2427{30:" barbarbarbarbarb}ar | 2428{103:+-- 3 lines: " 口}{13:···························}| 2429{30:" bazbazbazbazbaz^b}az | 2430{1:~ }|*2 2431{5:-- VISUAL BLOCK --} | 2432]] ) 2433end 2434 2435feed ( '2l' ) 2436if multigrid then 2437screen : expect ( [[ 2438## grid 1 2439[2:---------------------------------------------]|*7 2440[3:---------------------------------------------]| 2441## grid 2 2442{30:" foofoofoofoofoofoo} | 2443{103:+-- 3 lines: " 口··}{13:·························}| 2444{30:" barbarbarbarbarbar} | 2445{103:+-- 3 lines: " 口··}{13:·························}| 2446{30:" bazbazbazbazbazba^z} | 2447{1:~ }|*2 2448## grid 3 2449{5:-- VISUAL BLOCK --} | 2450]] ) 2451else 2452screen : expect ( [[ 2453{30:" foofoofoofoofoofoo} | 2454{103:+-- 3 lines: " 口··}{13:·························}| 2455{30:" barbarbarbarbarbar} | 2456{103:+-- 3 lines: " 口··}{13:·························}| 2457{30:" bazbazbazbazbazba^z} | 2458{1:~ }|*2 2459{5:-- VISUAL BLOCK --} | 2460]] ) 2461end 2462 2463feed ( 'O16l' ) 2464if multigrid then 2465screen : expect ( [[ 2466## grid 1 2467[2:---------------------------------------------]|*7 2468[3:---------------------------------------------]| 2469## grid 2 2470" foofoofoofoofo{30:ofoo} | 2471{13:+-- 3 lines: " }{103:口··}{13:·························}| 2472" barbarbarbarba{30:rbar} | 2473{13:+-- 3 lines: " }{103:口··}{13:·························}| 2474" bazbazbazbazba{30:^zbaz} | 2475{1:~ }|*2 2476## grid 3 2477{5:-- VISUAL BLOCK --} | 2478]] ) 2479else 2480screen : expect ( [[ 2481" foofoofoofoofo{30:ofoo} | 2482{13:+-- 3 lines: " }{103:口··}{13:·························}| 2483" barbarbarbarba{30:rbar} | 2484{13:+-- 3 lines: " }{103:口··}{13:·························}| 2485" bazbazbazbazba{30:^zbaz} | 2486{1:~ }|*2 2487{5:-- VISUAL BLOCK --} | 2488]] ) 2489end 2490 2491feed ( 'l' ) 2492if multigrid then 2493screen : expect ( [[ 2494## grid 1 2495[2:---------------------------------------------]|*7 2496[3:---------------------------------------------]| 2497## grid 2 2498" foofoofoofoofoo{30:foo} | 2499{13:+-- 3 lines: " }{103:口··}{13:·························}| 2500" barbarbarbarbar{30:bar} | 2501{13:+-- 3 lines: " }{103:口··}{13:·························}| 2502" bazbazbazbazbaz{30:^baz} | 2503{1:~ }|*2 2504## grid 3 2505{5:-- VISUAL BLOCK --} | 2506]] ) 2507else 2508screen : expect ( [[ 2509" foofoofoofoofoo{30:foo} | 2510{13:+-- 3 lines: " }{103:口··}{13:·························}| 2511" barbarbarbarbar{30:bar} | 2512{13:+-- 3 lines: " }{103:口··}{13:·························}| 2513" bazbazbazbazbaz{30:^baz} | 2514{1:~ }|*2 2515{5:-- VISUAL BLOCK --} | 2516]] ) 2517end 2518end ) 2519 2520it ( 'do not show search or match highlight #24084' , function () 2521insert ( [[ 2522line 1 2523line 2 2524line 3 2525line 4]] ) 2526command ( '2,3fold' ) 2527feed ( '/line' ) 2528if multigrid then 2529screen : expect ( [[ 2530## grid 1 2531[2:---------------------------------------------]|*7 2532[3:---------------------------------------------]| 2533## grid 2 2534{2:line} 1 | 2535{13:+-- 2 lines: line 2·························}| 2536{10:line} 4 | 2537{1:~ }|*4 2538## grid 3 2539/line^ | 2540]] ) 2541else 2542screen : expect ( [[ 2543{2:line} 1 | 2544{13:+-- 2 lines: line 2·························}| 2545{10:line} 4 | 2546{1:~ }|*4 2547/line^ | 2548]] ) 2549end 2550feed ( '<Esc>' ) 2551fn . matchadd ( 'Search' , 'line' ) 2552if multigrid then 2553screen : expect ( [[ 2554## grid 1 2555[2:---------------------------------------------]|*7 2556[3:---------------------------------------------]| 2557## grid 2 2558{10:line} 1 | 2559{13:+-- 2 lines: line 2·························}| 2560{10:line} ^4 | 2561{1:~ }|*4 2562## grid 3 2563| 2564]] ) 2565else 2566screen : expect ( [[ 2567{10:line} 1 | 2568{13:+-- 2 lines: line 2·························}| 2569{10:line} ^4 | 2570{1:~ }|*4 2571| 2572]] ) 2573end 2574end ) 2575 2576it ( 'foldtext with virtual text format' , function () 2577screen : try_resize ( 30 , 7 ) 2578insert ( content1 ) 2579command ( 'hi! CursorLine guibg=NONE guifg=Red gui=NONE' ) 2580command ( 'hi F0 guibg=Red guifg=Black' ) 2581command ( 'hi F1 guifg=White' ) 2582api . nvim_set_option_value ( 'cursorline' , true , {} ) 2583api . nvim_set_option_value ( 'foldcolumn' , '4' , {} ) 2584api . nvim_set_option_value ( 2585'foldtext' , 2586'[' 2587.. '["▶", ["F0", "F1"]], ' 2588.. '[v:folddashes], ' 2589.. '["\t", "Search"], ' 2590.. '[getline(v:foldstart), "NonText"]]' , 2591{} 2592) 2593 2594command ( '3,4fold' ) 2595command ( '5,6fold' ) 2596command ( '2,6fold' ) 2597if multigrid then 2598screen : expect ( [[ 2599## grid 1 2600[2:------------------------------]|*6 2601[3:------------------------------]| 2602## grid 2 2603{7: }This is a | 2604{7:+ }{9:^▶}{101:-}{20: }{104:valid English}{101:·····}| 2605{1:~ }|*4 2606## grid 3 2607| 2608]] ) 2609else 2610screen : expect ( [[ 2611{7: }This is a | 2612{7:+ }{9:^▶}{101:-}{20: }{104:valid English}{101:·····}| 2613{1:~ }|*4 2614| 2615]] ) 2616end 2617eq ( '▶-\tvalid English' , fn . foldtextresult ( 2 )) 2618 2619feed ( 'zo' ) 2620if multigrid then 2621screen : expect ( [[ 2622## grid 1 2623[2:------------------------------]|*6 2624[3:------------------------------]| 2625## grid 2 2626{7: }This is a | 2627{7:- }valid English | 2628{7:│+ }{9:▶}{13:--}{105: }{104:sentence composed }| 2629{7:│+ }{9:^▶}{101:--}{20: }{104:in his cave.}{101:······}| 2630{1:~ }|*2 2631## grid 3 2632| 2633]] ) 2634else 2635screen : expect ( [[ 2636{7: }This is a | 2637{7:- }valid English | 2638{7:│+ }{9:▶}{13:--}{105: }{104:sentence composed }| 2639{7:│+ }{9:^▶}{101:--}{20: }{104:in his cave.}{101:······}| 2640{1:~ }|*2 2641| 2642]] ) 2643end 2644eq ( '▶--\tsentence composed by' , fn . foldtextresult ( 3 )) 2645eq ( '▶--\tin his cave.' , fn . foldtextresult ( 5 )) 2646 2647command ( 'hi! Visual guifg=NONE guibg=Red' ) 2648feed ( 'V2k' ) 2649if multigrid then 2650screen : expect ( [[ 2651## grid 1 2652[2:------------------------------]|*6 2653[3:------------------------------]| 2654## grid 2 2655{7: }This is a | 2656{7:- }{30:^valid English} | 2657{7:│+ }{9:▶}{103:--}{105: }{106:sentence composed }| 2658{7:│+ }{9:▶}{103:--}{105: }{106:in his cave.}{103:······}| 2659{1:~ }|*2 2660## grid 3 2661{5:-- VISUAL LINE --} | 2662]] ) 2663else 2664screen : expect ( [[ 2665{7: }This is a | 2666{7:- }{30:^valid English} | 2667{7:│+ }{9:▶}{103:--}{105: }{106:sentence composed }| 2668{7:│+ }{9:▶}{103:--}{105: }{106:in his cave.}{103:······}| 2669{1:~ }|*2 2670{5:-- VISUAL LINE --} | 2671]] ) 2672end 2673 2674api . nvim_set_option_value ( 'rightleft' , true , {} ) 2675if multigrid then 2676screen : expect ( [[ 2677## grid 1 2678[2:------------------------------]|*6 2679[3:------------------------------]| 2680## grid 2 2681a si sihT{7: }| 2682{30:hsilgnE dila^v}{7: -}| 2683{106: desopmoc ecnetnes}{105: }{103:--}{9:▶}{7: +│}| 2684{103:······}{106:.evac sih ni}{105: }{103:--}{9:▶}{7: +│}| 2685{1: ~}|*2 2686## grid 3 2687{5:-- VISUAL LINE --} | 2688]] ) 2689else 2690screen : expect ( [[ 2691a si sihT{7: }| 2692{30:hsilgnE dila^v}{7: -}| 2693{106: desopmoc ecnetnes}{105: }{103:--}{9:▶}{7: +│}| 2694{103:······}{106:.evac sih ni}{105: }{103:--}{9:▶}{7: +│}| 2695{1: ~}|*2 2696{5:-- VISUAL LINE --} | 2697]] ) 2698end 2699end ) 2700 2701it ( 'transparent foldtext' , function () 2702screen : try_resize ( 30 , 7 ) 2703insert ( content1 ) 2704command ( 'hi! CursorLine guibg=NONE guifg=Red gui=NONE' ) 2705command ( [[syn match Keyword /\<sentence\>/]] ) 2706command ( 'hi! Keyword guibg=NONE guifg=Green' ) 2707api . nvim_set_option_value ( 'cursorline' , true , {} ) 2708api . nvim_set_option_value ( 'foldcolumn' , '4' , {} ) 2709api . nvim_set_option_value ( 'foldtext' , '' , {} ) 2710 2711command ( '3,4fold' ) 2712command ( '5,6fold' ) 2713command ( '2,6fold' ) 2714if multigrid then 2715screen : expect ( [[ 2716## grid 1 2717[2:------------------------------]|*6 2718[3:------------------------------]| 2719## grid 2 2720{7: }This is a | 2721{7:+ }{101:^valid English·············}| 2722{1:~ }|*4 2723## grid 3 2724| 2725]] ) 2726else 2727screen : expect ( [[ 2728{7: }This is a | 2729{7:+ }{101:^valid English·············}| 2730{1:~ }|*4 2731| 2732]] ) 2733end 2734 2735feed ( 'zo' ) 2736if multigrid then 2737screen : expect ( [[ 2738## grid 1 2739[2:------------------------------]|*6 2740[3:------------------------------]| 2741## grid 2 2742{7: }This is a | 2743{7:- }valid English | 2744{7:│+ }{107:sentence}{13: composed by······}| 2745{7:│+ }{101:^in his cave.··············}| 2746{1:~ }|*2 2747## grid 3 2748| 2749]] ) 2750else 2751screen : expect ( [[ 2752{7: }This is a | 2753{7:- }valid English | 2754{7:│+ }{107:sentence}{13: composed by······}| 2755{7:│+ }{101:^in his cave.··············}| 2756{1:~ }|*2 2757| 2758]] ) 2759end 2760 2761command ( 'hi! Visual guifg=NONE guibg=Red' ) 2762feed ( 'V2k' ) 2763if multigrid then 2764screen : expect ( [[ 2765## grid 1 2766[2:------------------------------]|*6 2767[3:------------------------------]| 2768## grid 2 2769{7: }This is a | 2770{7:- }{30:^valid English} | 2771{7:│+ }{108:sentence}{103: composed by······}| 2772{7:│+ }{103:in his cave.··············}| 2773{1:~ }|*2 2774## grid 3 2775{5:-- VISUAL LINE --} | 2776]] ) 2777else 2778screen : expect ( [[ 2779{7: }This is a | 2780{7:- }{30:^valid English} | 2781{7:│+ }{108:sentence}{103: composed by······}| 2782{7:│+ }{103:in his cave.··············}| 2783{1:~ }|*2 2784{5:-- VISUAL LINE --} | 2785]] ) 2786end 2787 2788api . nvim_set_option_value ( 'rightleft' , true , {} ) 2789if multigrid then 2790screen : expect ( [[ 2791## grid 1 2792[2:------------------------------]|*6 2793[3:------------------------------]| 2794## grid 2 2795a si sihT{7: }| 2796{30:hsilgnE dila^v}{7: -}| 2797{103:······yb desopmoc }{108:ecnetnes}{7: +│}| 2798{103:··············.evac sih ni}{7: +│}| 2799{1: ~}|*2 2800## grid 3 2801{5:-- VISUAL LINE --} | 2802]] ) 2803else 2804screen : expect ( [[ 2805a si sihT{7: }| 2806{30:hsilgnE dila^v}{7: -}| 2807{103:······yb desopmoc }{108:ecnetnes}{7: +│}| 2808{103:··············.evac sih ni}{7: +│}| 2809{1: ~}|*2 2810{5:-- VISUAL LINE --} | 2811]] ) 2812end 2813 2814api . nvim_set_option_value ( 'rightleft' , false , {} ) 2815api . nvim_set_option_value ( 'wrap' , false , {} ) 2816feed ( '<Esc>zl' ) 2817if multigrid then 2818screen : expect ( [[ 2819## grid 1 2820[2:------------------------------]|*6 2821[3:------------------------------]| 2822## grid 2 2823{7: }his is a | 2824{7:- }{100:^alid English }| 2825{7:│+ }{107:entence}{13: composed by·······}| 2826{7:│+ }{13:n his cave.···············}| 2827{1:~ }|*2 2828## grid 3 2829| 2830]] ) 2831else 2832screen : expect ( [[ 2833{7: }his is a | 2834{7:- }{100:^alid English }| 2835{7:│+ }{107:entence}{13: composed by·······}| 2836{7:│+ }{13:n his cave.···············}| 2837{1:~ }|*2 2838| 2839]] ) 2840end 2841 2842fn . append ( 0 , ( '!' ): rep ( 15 )) 2843feed ( 'gg$zs' ) 2844if multigrid then 2845screen : expect ( [[ 2846## grid 1 2847[2:------------------------------]|*6 2848[3:------------------------------]| 2849## grid 2 2850{7: }{100:^! }| 2851{7: } | 2852{7:- } | 2853{7:│+ }{13:sed by····················}| 2854{7:│+ }{13:··························}| 2855{1:~ }| 2856## grid 3 2857| 2858]] ) 2859else 2860screen : expect ( [[ 2861{7: }{100:^! }| 2862{7: } | 2863{7:- } | 2864{7:│+ }{13:sed by····················}| 2865{7:│+ }{13:··························}| 2866{1:~ }| 2867| 2868]] ) 2869end 2870end ) 2871 2872it ( 'transparent foldtext filler text search highlighting' , function () 2873screen : try_resize ( 30 , 7 ) 2874insert ( content1 ) 2875api . nvim_set_option_value ( 'foldtext' , '' , {} ) 2876 2877command ( "3,4fold | let v:hlsearch = 1 | let @/ = '.'" ) 2878if multigrid then 2879screen : expect ( [[ 2880## grid 1 2881[2:------------------------------]|*6 2882[3:------------------------------]| 2883## grid 2 2884{10:This is a} | 2885{10:valid English} | 2886{105:sentence composed by}{13:··········}| 2887{10:in his cave.} | 2888^ | 2889{1:~ }| 2890## grid 3 2891| 2892]] ) 2893else 2894screen : expect ( [[ 2895{10:This is a} | 2896{10:valid English} | 2897{105:sentence composed by}{13:··········}| 2898{10:in his cave.} | 2899^ | 2900{1:~ }| 2901| 2902]] ) 2903end 2904 2905command ( "let @/ = '$'" ) 2906if multigrid then 2907screen : expect ( [[ 2908## grid 1 2909[2:------------------------------]|*6 2910[3:------------------------------]| 2911## grid 2 2912This is a{10: } | 2913valid English{10: } | 2914{13:sentence composed by}{105:·}{13:·········}| 2915in his cave.{10: } | 2916{10:^ } | 2917{1:~ }| 2918## grid 3 2919| 2920]] ) 2921else 2922screen : expect ( [[ 2923This is a{10: } | 2924valid English{10: } | 2925{13:sentence composed by}{105:·}{13:·········}| 2926in his cave.{10: } | 2927{10:^ } | 2928{1:~ }| 2929| 2930]] ) 2931end 2932 2933command ( "let @/ = '.\\?'" ) 2934if multigrid then 2935screen : expect ( [[ 2936## grid 1 2937[2:------------------------------]|*6 2938[3:------------------------------]| 2939## grid 2 2940{10:This is a } | 2941{10:valid English } | 2942{105:sentence composed by·}{13:·········}| 2943{10:in his cave. } | 2944{10:^ } | 2945{1:~ }| 2946## grid 3 2947| 2948]] ) 2949else 2950screen : expect ( [[ 2951{10:This is a } | 2952{10:valid English } | 2953{105:sentence composed by·}{13:·········}| 2954{10:in his cave. } | 2955{10:^ } | 2956{1:~ }| 2957| 2958]] ) 2959end 2960 2961command ( 'set list' ) 2962screen : expect_unchanged () -- No "eol" set for &listchars yet. 2963 2964command ( "set listchars+=eol:& | let @/ = '.'" ) 2965if multigrid then 2966screen : expect ( [[ 2967## grid 1 2968[2:------------------------------]|*6 2969[3:------------------------------]| 2970## grid 2 2971{10:This is a}{1:&} | 2972{10:valid English}{1:&} | 2973{105:sentence composed by}{104:&}{13:·········}| 2974{10:in his cave.}{1:&} | 2975{1:^&} | 2976{1:~ }| 2977## grid 3 2978| 2979]] ) 2980else 2981screen : expect ( [[ 2982{10:This is a}{1:&} | 2983{10:valid English}{1:&} | 2984{105:sentence composed by}{104:&}{13:·········}| 2985{10:in his cave.}{1:&} | 2986{1:^&} | 2987{1:~ }| 2988| 2989]] ) 2990end 2991 2992command ( "let @/ = '$'" ) 2993if multigrid then 2994screen : expect ( [[ 2995## grid 1 2996[2:------------------------------]|*6 2997[3:------------------------------]| 2998## grid 2 2999This is a{109:&} | 3000valid English{109:&} | 3001{13:sentence composed by}{109:&}{13:·········}| 3002in his cave.{109:&} | 3003{109:^&} | 3004{1:~ }| 3005## grid 3 3006| 3007]] ) 3008else 3009screen : expect ( [[ 3010This is a{109:&} | 3011valid English{109:&} | 3012{13:sentence composed by}{109:&}{13:·········}| 3013in his cave.{109:&} | 3014{109:^&} | 3015{1:~ }| 3016| 3017]] ) 3018end 3019 3020command ( "let @/ = '.\\?'" ) 3021if multigrid then 3022screen : expect ( [[ 3023## grid 1 3024[2:------------------------------]|*6 3025[3:------------------------------]| 3026## grid 2 3027{10:This is a}{109:&} | 3028{10:valid English}{109:&} | 3029{105:sentence composed by}{109:&}{13:·········}| 3030{10:in his cave.}{109:&} | 3031{109:^&} | 3032{1:~ }| 3033## grid 3 3034| 3035]] ) 3036else 3037screen : expect ( [[ 3038{10:This is a}{109:&} | 3039{10:valid English}{109:&} | 3040{105:sentence composed by}{109:&}{13:·········}| 3041{10:in his cave.}{109:&} | 3042{109:^&} | 3043{1:~ }| 3044| 3045]] ) 3046end 3047end ) 3048end 3049 3050describe ( 'with ext_multigrid' , function () 3051with_ext_multigrid ( true ) 3052end ) 3053 3054describe ( 'without ext_multigrid' , function () 3055with_ext_multigrid ( false ) 3056end ) 3057 3058it ( 'does not hang drawing diff filler above a folded line' , function () 3059Screen . new ( 80 , 24 ) 3060exec ( [[ 3061call setline(1, ['fold', 'body']) 3062vnew 3063call setline(1, ['inserted', 'fold', 'body']) 3064 3065windo diffthis 3066wincmd l 3067setlocal foldmethod=manual 30681,2fold 3069normal! zM 3070 3071wincmd h 3072normal! 1Gzt 3073redraw 3074 3075let g:diff_filler_fold_done = 1 3076]] ) 3077eq ( 1 , api . nvim_get_var ( 'diff_filler_fold_done' )) 3078assert_alive () 3079end ) 3080 3081it ( "do not interfere with corrected cursor position for 'scrolloff'" , function () 3082local screen =Screen . new ( 40 , 7 ) 3083exec ( [[ 3084call setline(1, range(10)) 30856,7fold 3086set scrolloff=1 3087norm L 3088]] ) 3089screen : expect ( [[ 30900 | 30911 | 30922 | 30933 | 3094^4 | 3095{13:+-- 2 lines: 5·························}| 3096| 3097]] ) 3098end ) 3099end )