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' ) 4local os =require ( 'os' ) 5 6local describe , it , before_each , after_each =t . describe , t . it , t . before_each , t . after_each 7local clear , feed , insert =n . clear , n . feed , n . insert 8local command , exec =n . command , n . exec 9local eval =n . eval 10local feed_command , eq =n . feed_command , t . eq 11local fn =n . fn 12local api =n . api 13local exec_lua =n . exec_lua 14 15describe ( 'colorscheme compatibility' , function () 16before_each ( function () 17clear () 18end ) 19 20it ( '&t_Co exists and is set to 256 by default' , function () 21eq ( 1 , fn . exists ( '&t_Co' )) 22eq ( 1 , fn . exists ( '+t_Co' )) 23eq ( '256' , eval ( '&t_Co' )) 24end ) 25end ) 26 27describe ( 'highlight: `:syntax manual`' , function () 28-- When using manual syntax highlighting, it should be preserved even when 29-- switching buffers... bug did only occur without :set hidden 30-- Ref: vim patch 7.4.1236 31local screen 32 33before_each ( function () 34clear () 35screen =Screen . new ( 20 , 5 ) 36-- syntax highlight for vimscript's "echo" 37end ) 38 39after_each ( function () 40os . remove ( 'Xtest-functional-ui-highlight.tmp.vim' ) 41end ) 42 43it ( "works with buffer switch and 'hidden'" , function () 44command ( 'e tmp1.vim' ) 45command ( 'e Xtest-functional-ui-highlight.tmp.vim' ) 46command ( 'filetype on' ) 47command ( 'syntax manual' ) 48command ( 'set ft=vim' ) 49command ( 'set syntax=ON' ) 50feed ( 'iecho 1<esc>0' ) 51 52command ( 'set hidden' ) 53command ( 'w' ) 54command ( 'bn' ) 55feed_command ( 'bp' ) 56screen : expect ( [[ 57{15:^echo} {26:1} | 58{1:~ }|*3 59:bp | 60]] ) 61end ) 62 63it ( "works with buffer switch and 'nohidden'" , function () 64command ( 'e tmp1.vim' ) 65command ( 'e Xtest-functional-ui-highlight.tmp.vim' ) 66command ( 'filetype on' ) 67command ( 'syntax manual' ) 68command ( 'set filetype=vim fileformat=unix' ) 69command ( 'set syntax=ON' ) 70feed ( 'iecho 1<esc>0' ) 71 72command ( 'set nohidden' ) 73command ( 'w' ) 74command ( 'silent bn' ) 75eq ( 'tmp1.vim' , eval ( "fnamemodify(bufname('%'), ':t')" )) 76feed_command ( 'silent bp' ) 77eq ( 'Xtest-functional-ui-highlight.tmp.vim' , eval ( "fnamemodify(bufname('%'), ':t')" )) 78screen : expect ( [[ 79{15:^echo} {26:1} | 80{1:~ }|*3 81:silent bp | 82]] ) 83end ) 84end ) 85 86describe ( 'highlight defaults' , function () 87local screen 88 89before_each ( function () 90clear () 91screen =Screen . new () 92screen : add_extra_attr_ids { 93[ 100 ] ={ foreground =Screen . colors . Red , background =Screen . colors . WebGreen } , 94[ 101 ] ={ italic =true } , 95} 96end ) 97 98it ( 'window status bar' , function () 99feed_command ( 'sp' , 'vsp' , 'vsp' ) 100screen : expect ( [[ 101^ │ │ | 102{1:~ }│{1:~ }│{1:~ }|*5 103{3:[No Name] }{2:[No Name] [No Name] }| 104| 105{1:~ }|*4 106{2:[No Name] }| 107:vsp | 108]] ) 109-- navigate to verify that the attributes are properly moved 110feed ( '<c-w>j' ) 111screen : expect ( [[ 112│ │ | 113{1:~ }│{1:~ }│{1:~ }|*5 114{2:[No Name] [No Name] [No Name] }| 115^ | 116{1:~ }|*4 117{3:[No Name] }| 118:vsp | 119]] ) 120-- note that when moving to a window with small width nvim will increase 121-- the width of the new active window at the expense of a inactive window 122-- (upstream vim has the same behavior) 123feed ( '<c-w>k<c-w>l' ) 124screen : expect ( [[ 125│^ │ | 126{1:~ }│{1:~ }│{1:~ }|*5 127{2:[No Name] }{3:[No Name] }{2:[No Name] }| 128| 129{1:~ }|*4 130{2:[No Name] }| 131:vsp | 132]] ) 133feed ( '<c-w>l' ) 134screen : expect ( [[ 135│ │^ | 136{1:~ }│{1:~ }│{1:~ }|*5 137{2:[No Name] [No Name] }{3:[No Name] }| 138| 139{1:~ }|*4 140{2:[No Name] }| 141:vsp | 142]] ) 143feed ( '<c-w>h<c-w>h' ) 144screen : expect ( [[ 145^ │ │ | 146{1:~ }│{1:~ }│{1:~ }|*5 147{3:[No Name] }{2:[No Name] [No Name] }| 148| 149{1:~ }|*4 150{2:[No Name] }| 151:vsp | 152]] ) 153end ) 154 155it ( 'insert mode text' , function () 156feed ( 'i' ) 157screen : try_resize ( 53 , 4 ) 158screen : expect ( [[ 159^ | 160{1:~ }|*2 161{5:-- INSERT --} | 162]] ) 163end ) 164 165it ( 'end of file markers' , function () 166screen : try_resize ( 53 , 4 ) 167screen : expect ( [[ 168^ | 169{1:~ }|*2 170| 171]] ) 172end ) 173 174it ( '"wait return" text' , function () 175screen : try_resize ( 53 , 4 ) 176feed ( ':ls<cr>' ) 177screen : expect ( [[ 178{3: }| 179:ls | 1801 %a "[No Name]" line 1 | 181{6:Press ENTER or type command to continue}^ | 182]] ) 183feed ( '<cr>' ) -- skip the "Press ENTER..." state or tests will hang 184end ) 185 186it ( 'can be cleared and linked to other highlight groups' , function () 187screen : try_resize ( 53 , 4 ) 188feed_command ( 'highlight clear ModeMsg' ) 189feed ( 'i' ) 190screen : expect ( [[ 191^ | 192{1:~ }|*2 193-- INSERT -- | 194]] ) 195feed ( '<esc>' ) 196feed_command ( 'highlight CustomHLGroup guifg=red guibg=green' ) 197feed_command ( 'highlight link ModeMsg CustomHLGroup' ) 198feed ( 'i' ) 199screen : expect ( [[ 200^ | 201{1:~ }|*2 202{100:-- INSERT --} | 203]] ) 204end ) 205 206it ( 'can be cleared by assigning NONE' , function () 207screen : try_resize ( 53 , 4 ) 208feed_command ( 'syn keyword TmpKeyword neovim' ) 209feed_command ( 'hi link TmpKeyword ErrorMsg' ) 210insert ( 'neovim' ) 211screen : expect ( [[ 212{9:neovi^m} | 213{1:~ }|*2 214| 215]] ) 216feed_command ( 217'hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE' 218.. ' gui=NONE guifg=NONE guibg=NONE guisp=NONE' 219) 220screen : expect ( [[ 221neovi^m | 222{1:~ }|*2 223| 224]] ) 225end ) 226 227it ( 'linking updates window highlight immediately #16552' , function () 228screen : try_resize ( 53 , 4 ) 229screen : expect ( [[ 230^ | 231{1:~ }|*2 232| 233]] ) 234feed_command ( 'hi NonTextAlt guifg=Red' ) 235feed_command ( 'hi! link NonText NonTextAlt' ) 236screen : expect ( [[ 237^ | 238{19:~ }|*2 239:hi! link NonText NonTextAlt | 240]] ) 241end ) 242 243it ( 'Cursor after `:hi clear|syntax reset` #6508' , function () 244command ( 'highlight clear|syntax reset' ) 245eq ( 246'cterm=reverse guifg=bg guibg=fg' , 247eval ( [[matchstr(execute('hi Cursor'), '\v(gui|cterm).*$')]] ) 248) 249end ) 250 251it ( 'Whitespace highlight' , function () 252screen : try_resize ( 53 , 4 ) 253feed_command ( 'highlight NonText gui=NONE guifg=#FF0000' ) 254feed_command ( 'set listchars=space:.,tab:>-,trail:*,eol:¬ list' ) 255insert ( ' ne \t o\tv im ' ) 256screen : expect ( [[ 257ne{19:.>----.}o{19:>-----}v{19:..}im{19:*^*¬} | 258{19:~ }|*2 259| 260]] ) 261feed_command ( 'highlight Whitespace gui=NONE guifg=#0000FF' ) 262screen : expect ( [[ 263ne{18:.>----.}o{18:>-----}v{18:..}im{18:*^*}{19:¬} | 264{19:~ }|*2 265:highlight Whitespace gui=NONE guifg=#0000FF | 266]] ) 267end ) 268 269it ( 'are sent to UIs' , function () 270screen : try_resize ( 53 , 4 ) 271 272screen : expect { 273grid =[[ 274^ | 275{1:~ }|*2 276| 277]] , 278hl_groups ={ EndOfBuffer =1 , MsgSeparator =3 } , 279} 280 281command ( 'highlight EndOfBuffer gui=italic' ) 282screen : expect { 283grid =[[ 284^ | 285{101:~ }|*2 286| 287]] , 288hl_groups ={ EndOfBuffer =101 , MsgSeparator =3 } , 289} 290 291command ( 'highlight clear EndOfBuffer' ) 292screen : expect { 293grid =[[ 294^ | 295{1:~ }|*2 296| 297]] , 298hl_groups ={ EndOfBuffer =1 , MsgSeparator =3 } , 299} 300end ) 301end ) 302 303describe ( 'highlight' , function () 304before_each ( clear ) 305 306it ( 'Visual' , function () 307local screen =Screen . new ( 45 , 5 ) 308insert ( [[ 309line1 foo bar 310abcdefghijklmnopqrs 311ABCDEFGHIJKLMNOPQRS 312]] ) 313feed ( 'gg' ) 314command ( 'vsplit' ) 315 316-- Visual highlighting does not depend on 'guicursor'. 317command ( 'set guicursor=a:block-blinkon0' ) 318feed ( 'V' ) 319screen : expect ( [[ 320{17: ^line1 foo bar} │{17: line1 foo bar} | 321abcdefghijklmnopqrs │abcdefghijklmnopqrs | 322ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | 323{3:[No Name] [+] }{2:[No Name] [+] }| 324{5:-- VISUAL LINE --} | 325]] ) 326 327feed ( '<Esc>$vhhh' ) 328screen : expect ( [[ 329line1 foo{17:^ bar} │ line1 foo{17: bar} | 330abcdefghijklmnopqrs │abcdefghijklmnopqrs | 331ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | 332{3:[No Name] [+] }{2:[No Name] [+] }| 333{5:-- VISUAL --} | 334]] ) 335 336-- Non-blinking block cursor with blinkon0 does not affect Visual highlighting either. #8983 337command ( 'set guicursor=a:block-blinkon175' ) 338screen : expect ( [[ 339line1 foo{17:^ bar} │ line1 foo{17: bar} | 340abcdefghijklmnopqrs │abcdefghijklmnopqrs | 341ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | 342{3:[No Name] [+] }{2:[No Name] [+] }| 343{5:-- VISUAL --} | 344]] ) 345 346command ( 'set selection=exclusive' ) 347screen : expect ( [[ 348line1 foo{17:^ ba}r │ line1 foo{17: ba}r | 349abcdefghijklmnopqrs │abcdefghijklmnopqrs | 350ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | 351{3:[No Name] [+] }{2:[No Name] [+] }| 352{5:-- VISUAL --} | 353]] ) 354 355feed ( 'o' ) 356screen : expect ( [[ 357line1 foo{17: ba}^r │ line1 foo{17: ba}r | 358abcdefghijklmnopqrs │abcdefghijklmnopqrs | 359ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | 360{3:[No Name] [+] }{2:[No Name] [+] }| 361{5:-- VISUAL --} | 362]] ) 363 364feed ( 'V' ) 365screen : expect ( [[ 366{17: line1 foo ba^r} │{17: line1 foo bar} | 367abcdefghijklmnopqrs │abcdefghijklmnopqrs | 368ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | 369{3:[No Name] [+] }{2:[No Name] [+] }| 370{5:-- VISUAL LINE --} | 371]] ) 372 373command ( 'set cursorcolumn' ) 374feed ( '<C-V>' ) 375screen : expect ( [[ 376line1 foo{17: ba}^r │ line1 foo{17: ba}r | 377abcdefghijklmn{21:o}pqrs │abcdefghijklmnopqrs | 378ABCDEFGHIJKLMN{21:O}PQRS │ABCDEFGHIJKLMNOPQRS | 379{3:[No Name] [+] }{2:[No Name] [+] }| 380{5:-- VISUAL BLOCK --} | 381]] ) 382 383command ( 'set selection&' ) 384screen : expect ( [[ 385line1 foo{17: ba^r} │ line1 foo{17: bar} | 386abcdefghijklmn{21:o}pqrs │abcdefghijklmnopqrs | 387ABCDEFGHIJKLMN{21:O}PQRS │ABCDEFGHIJKLMNOPQRS | 388{3:[No Name] [+] }{2:[No Name] [+] }| 389{5:-- VISUAL BLOCK --} | 390]] ) 391 392feed ( '^' ) 393screen : expect ( [[ 394{17:^line1 foo }bar │ {17:line1 foo }bar | 395ab{21:c}defghijklmnopqrs │abcdefghijklmnopqrs | 396AB{21:C}DEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | 397{3:[No Name] [+] }{2:[No Name] [+] }| 398{5:-- VISUAL BLOCK --} | 399]] ) 400 401feed ( '2j' ) 402screen : expect ( [[ 403{17:line1 foo }bar │ {17:line1 foo }bar | 404ab{17:cdefghijkl}mnopqrs │ab{17:cdefghijkl}mnopqrs | 405AB{17:^CDEFGHIJKL}MNOPQRS │AB{17:CDEFGHIJKL}MNOPQRS | 406{3:[No Name] [+] }{2:[No Name] [+] }| 407{5:-- VISUAL BLOCK --} | 408]] ) 409 410command ( 'set nocursorcolumn' ) 411feed ( 'O' ) 412screen : expect ( [[ 413{17:line1 foo }bar │ {17:line1 foo }bar | 414ab{17:cdefghijkl}mnopqrs │ab{17:cdefghijkl}mnopqrs | 415AB{17:CDEFGHIJK^L}MNOPQRS │AB{17:CDEFGHIJKL}MNOPQRS | 416{3:[No Name] [+] }{2:[No Name] [+] }| 417{5:-- VISUAL BLOCK --} | 418]] ) 419 420command ( 'set selection=exclusive' ) 421screen : expect ( [[ 422{17:line1 foo} bar │ {17:line1 foo} bar | 423ab{17:cdefghijk}lmnopqrs │ab{17:cdefghijk}lmnopqrs | 424AB{17:CDEFGHIJK}^LMNOPQRS │AB{17:CDEFGHIJK}LMNOPQRS | 425{3:[No Name] [+] }{2:[No Name] [+] }| 426{5:-- VISUAL BLOCK --} | 427]] ) 428end ) 429 430it ( 'blockwise Visual highlight with virtualedit=block #34235' , function () 431local screen =Screen . new ( 45 , 5 ) 432command ( 'set virtualedit=block' ) 433insert ( 'foobar\nfoo' ) 434feed ( '0<C-V>k$' ) 435screen : expect ( [[ 436{17:foobar^ } | 437{17:foo } | 438{1:~ }|*2 439{5:-- VISUAL BLOCK --} | 440]] ) 441feed ( '10l' ) 442screen : expect ( [[ 443{17:foobar ^ } | 444{17:foo } | 445{1:~ }|*2 446{5:-- VISUAL BLOCK --} | 447]] ) 448end ) 449 450it ( "is updated with H/L and 'scrolloff' #36059" , function () 451local screen =Screen . new ( 40 , 10 ) 452exec ( [[ 453call setline(1, map(range(1, 100), "'line ' .. v:val")) 454set scrolloff=2 nostartofline 455call cursor(50, 1) 456]] ) 457feed ( 'z<CR>V' ) 458screen : expect ( [[ 459line 48 | 460line 49 | 461{17:^line 50} | 462line 51 | 463line 52 | 464line 53 | 465line 54 | 466line 55 | 467line 56 | 468{5:-- VISUAL LINE --} | 469]] ) 470feed ( 'L' ) 471screen : expect ( [[ 472line 48 | 473line 49 | 474{17:line 50} | 475{17:line 51} | 476{17:line 52} | 477{17:line 53} | 478{17:^line 54} | 479line 55 | 480line 56 | 481{5:-- VISUAL LINE --} | 482]] ) 483feed ( '<Esc>V' ) 484screen : expect ( [[ 485line 48 | 486line 49 | 487line 50 | 488line 51 | 489line 52 | 490line 53 | 491{17:^line 54} | 492line 55 | 493line 56 | 494{5:-- VISUAL LINE --} | 495]] ) 496feed ( 'H' ) 497screen : expect ( [[ 498line 48 | 499line 49 | 500{17:^line 50} | 501{17:line 51} | 502{17:line 52} | 503{17:line 53} | 504{17:line 54} | 505line 55 | 506line 56 | 507{5:-- VISUAL LINE --} | 508]] ) 509end ) 510 511it ( 'cterm=standout gui=standout' , function () 512local screen =Screen . new ( 20 , 5 ) 513screen : add_extra_attr_ids { 514[ 100 ] ={ 515foreground =Screen . colors . Blue1 , 516bold =true , 517background =Screen . colors . Grey90 , 518underline =true , 519standout =true , 520} , 521[ 101 ] ={ underline =true , standout =true , background =Screen . colors . Grey90 } , 522} 523feed_command ( 'hi CursorLine cterm=standout,underline gui=standout,underline' ) 524feed_command ( 'set cursorline' ) 525feed_command ( 'set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list' ) 526feed ( 'i\t abcd <cr>\t abcd <cr><esc>k' ) 527screen : expect ( [[ 528{1:>-------.}abcd{1:*¬} | 529{100:^>-------.}{101:abcd}{100:*¬}{101: }| 530{1:¬} | 531{1:~ }| 532| 533]] ) 534end ) 535 536it ( 'strikethrough' , function () 537local screen =Screen . new ( 25 , 6 ) 538feed_command ( 'syntax on' ) 539feed_command ( 'syn keyword TmpKeyword foo' ) 540feed_command ( 'hi! Awesome cterm=strikethrough gui=strikethrough' ) 541feed_command ( 'hi link TmpKeyword Awesome' ) 542insert ( [[ 543foo 544foo bar 545foobarfoobar 546]] ) 547screen : expect ( 548[[ 549{1:foo} | 550{1:foo} bar | 551foobarfoobar | 552^ | 553{2:~ }| 554| 555]] , 556{ 557[ 1 ] ={ strikethrough =true } , 558[ 2 ] ={ bold =true , foreground =Screen . colors . Blue1 } , 559} 560) 561end ) 562 563it ( 'nocombine' , function () 564local screen =Screen . new ( 25 , 6 ) 565screen : add_extra_attr_ids { 566[ 100 ] ={ underline =true , reverse =true , foreground =Screen . colors . SlateBlue } , 567[ 101 ] ={ 568foreground =Screen . colors . SlateBlue , 569reverse =true , 570background =Screen . colors . Yellow , 571} , 572} 573feed_command ( 'syntax on' ) 574feed_command ( 'hi! Underlined cterm=underline gui=underline' ) 575feed_command ( 'syn keyword Underlined foobar' ) 576feed_command ( 'hi Search cterm=inverse,nocombine gui=inverse,nocombine' ) 577insert ( [[ 578foobar 579foobar 580]] ) 581screen : expect { 582grid =[[ 583{28:foobar} |*2 584^ | 585{1:~ }|*2 586| 587]] , 588} 589 590feed ( '/foo' ) 591screen : expect { 592grid =[[ 593{100:foo}{28:bar} | 594{101:foo}{28:bar} | 595| 596{1:~ }|*2 597/foo^ | 598]] , 599} 600feed ( '<cr>' ) 601screen : expect { 602grid =[[ 603{101:^foo}{28:bar} | 604{101:foo}{28:bar} | 605| 606{1:~ }|*2 607{19:search hit...uing at TOP} | 608]] , 609} 610end ) 611 612it ( 'guisp (special/undercurl)' , function () 613local screen =Screen . new ( 25 , 10 ) 614feed_command ( 'syntax on' ) 615feed_command ( 'syn keyword TmpKeyword neovim' ) 616feed_command ( 'syn keyword TmpKeyword1 special' ) 617feed_command ( 'syn keyword TmpKeyword2 specialwithbg' ) 618feed_command ( 'syn keyword TmpKeyword3 specialwithfg' ) 619feed_command ( 'hi! Awesome guifg=red guibg=yellow guisp=red' ) 620feed_command ( 'hi! Awesome1 guisp=red' ) 621feed_command ( 'hi! Awesome2 guibg=yellow guisp=red' ) 622feed_command ( 'hi! Awesome3 guifg=red guisp=red' ) 623feed_command ( 'hi link TmpKeyword Awesome' ) 624feed_command ( 'hi link TmpKeyword1 Awesome1' ) 625feed_command ( 'hi link TmpKeyword2 Awesome2' ) 626feed_command ( 'hi link TmpKeyword3 Awesome3' ) 627insert ( [[ 628neovim 629awesome neovim 630wordcontainingneovim 631special 632specialwithbg 633specialwithfg 634]] ) 635feed ( 'Go<tab>neovim tabbed' ) 636screen : expect ( 637[[ 638{1:neovim} | 639awesome {1:neovim} | 640wordcontainingneovim | 641{2:special} | 642{3:specialwithbg} | 643{4:specialwithfg} | 644| 645{1:neovim} tabbed^ | 646{0:~ }| 647{5:-- INSERT --} | 648]] , 649{ 650[ 0 ] ={ bold =true , foreground =Screen . colors . Blue } , 651[ 1 ] ={ 652background =Screen . colors . Yellow , 653foreground =Screen . colors . Red , 654special =Screen . colors . Red , 655} , 656[ 2 ] ={ special =Screen . colors . Red } , 657[ 3 ] ={ special =Screen . colors . Red , background =Screen . colors . Yellow } , 658[ 4 ] ={ foreground =Screen . colors . Red , special =Screen . colors . Red } , 659[ 5 ] ={ bold =true } , 660} 661) 662end ) 663 664it ( "'diff', syntax and extmark #23722" , function () 665local screen =Screen . new ( 25 , 10 ) 666exec ( [[ 667new 668call setline(1, ['', '01234 6789']) 669windo diffthis 670wincmd w 671syn match WarningMsg "^.*$" 672call nvim_buf_add_highlight(0, -1, 'ErrorMsg', 1, 2, 8) 673]] ) 674screen : expect ( 675[[ 676{1: }{5:^ }| 677{1: }{2:01}{3:234 67}{2:89}{5: }| 678{4:~ }|*2 679{7:[No Name] [+] }| 680{1: }{6:-----------------------}|*2 681{1: } | 682{8:[No Name] }| 683| 684]] , 685{ 686[ 0 ] ={ Screen . colors . WebGray , foreground =Screen . colors . DarkBlue } , 687[ 1 ] ={ background =Screen . colors . Grey , foreground =Screen . colors . Blue4 } , 688[ 2 ] ={ foreground =Screen . colors . Red , background =Screen . colors . LightBlue } , 689[ 3 ] ={ foreground =Screen . colors . Grey100 , background =Screen . colors . LightBlue } , 690[ 4 ] ={ bold =true , foreground =Screen . colors . Blue } , 691[ 5 ] ={ background =Screen . colors . LightBlue } , 692[ 6 ] ={ 693bold =true , 694background =Screen . colors . LightCyan , 695foreground =Screen . colors . Blue1 , 696} , 697[ 7 ] ={ reverse =true , bold =true } , 698[ 8 ] ={ reverse =true } , 699} 700) 701end ) 702end ) 703 704describe ( "'listchars' highlight" , function () 705local screen 706 707before_each ( function () 708clear () 709screen =Screen . new ( 20 , 5 ) 710end ) 711 712it ( "'cursorline' and 'cursorcolumn'" , function () 713feed_command ( 'highlight clear ModeMsg' ) 714feed_command ( 'set cursorline' ) 715feed ( 'i' ) 716screen : expect ( [[ 717{21:^ }| 718{1:~ }|*3 719-- INSERT -- | 720]] ) 721feed ( 'abcdefg<cr>kkasdf' ) 722screen : expect ( [[ 723abcdefg | 724{21:kkasdf^ }| 725{1:~ }|*2 726-- INSERT -- | 727]] ) 728feed ( '<esc>' ) 729screen : expect ( [[ 730abcdefg | 731{21:kkasd^f }| 732{1:~ }|*2 733| 734]] ) 735feed_command ( 'set nocursorline' ) 736screen : expect ( [[ 737abcdefg | 738kkasd^f | 739{1:~ }|*2 740:set nocursorline | 741]] ) 742feed ( 'k' ) 743screen : expect ( [[ 744abcde^fg | 745kkasdf | 746{1:~ }|*2 747:set nocursorline | 748]] ) 749feed ( 'jjji<cr><cr><cr><esc>' ) 750screen : expect ( [[ 751kkasd | 752|*2 753^f | 754| 755]] ) 756feed_command ( 'set cursorline' ) 757feed_command ( 'set cursorcolumn' ) 758feed ( 'kkiabcdefghijk<esc>hh' ) 759screen : expect ( [[ 760kkasd {21: } | 761{21:abcdefgh^ijk }| 762{21: } | 763f {21: } | 764| 765]] ) 766feed ( 'khh' ) 767screen : expect ( [[ 768{21:kk^asd }| 769ab{21:c}defghijk | 770{21: } | 771f {21: } | 772| 773]] ) 774end ) 775 776it ( "'cursorline' and with 'listchars' option" , function () 777screen : add_extra_attr_ids { 778[ 100 ] ={ foreground =Screen . colors . Red , background =Screen . colors . Grey90 } , 779[ 101 ] ={ foreground =Screen . colors . Blue1 , bold =true , background =Screen . colors . Grey90 } , 780} 781feed_command ( 'highlight clear ModeMsg' ) 782feed_command ( 'highlight Whitespace guifg=#FF0000' ) 783feed_command ( 'set cursorline' ) 784feed_command ( 'set tabstop=8' ) 785feed_command ( 'set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list' ) 786feed ( 'i\t abcd <cr>\t abcd <cr><esc>k' ) 787screen : expect ( [[ 788{19:>-------.}abcd{19:*}{1:¬} | 789{100:^>-------.}{21:abcd}{100:*}{101:¬}{21: }| 790{1:¬} | 791{1:~ }| 792| 793]] ) 794feed ( 'k' ) 795screen : expect ( [[ 796{100:^>-------.}{21:abcd}{100:*}{101:¬}{21: }| 797{19:>-------.}abcd{19:*}{1:¬} | 798{1:¬} | 799{1:~ }| 800| 801]] ) 802feed_command ( 'set nocursorline' ) 803screen : expect ( [[ 804{19:^>-------.}abcd{19:*}{1:¬} | 805{19:>-------.}abcd{19:*}{1:¬} | 806{1:¬} | 807{1:~ }| 808:set nocursorline | 809]] ) 810feed_command ( 'set nowrap' ) 811feed ( 'ALorem ipsum dolor sit amet<ESC>0' ) 812screen : expect ( [[ 813{19:^>-------.}abcd{19:.}Lorem{1:>}| 814{19:>-------.}abcd{19:*}{1:¬} | 815{1:¬} | 816{1:~ }| 817| 818]] ) 819feed_command ( 'set cursorline' ) 820screen : expect ( [[ 821{100:^>-------.}{21:abcd}{100:.}{21:Lorem}{101:>}| 822{19:>-------.}abcd{19:*}{1:¬} | 823{1:¬} | 824{1:~ }| 825:set cursorline | 826]] ) 827feed ( '$' ) 828screen : expect ( [[ 829{101:<}{21:r}{100:.}{21:sit}{100:.}{21:ame^t}{101:¬}{21: }| 830{1:<} |*2 831{1:~ }| 832:set cursorline | 833]] ) 834feed ( 'G' ) 835screen : expect ( [[ 836{19:>-------.}abcd{19:.}Lorem{1:>}| 837{19:>-------.}abcd{19:*}{1:¬} | 838{101:^¬}{21: }| 839{1:~ }| 840:set cursorline | 841]] ) 842end ) 843 844it ( "'listchar' with wrap" , function () 845feed_command ( 'set wrap' ) 846feed_command ( 'set listchars=eol:¬,precedes:< list' ) 847feed ( '90ia<esc>' ) 848screen : expect ( [[ 849{1:<}aaaaaaaaaaaaaaaaaaa| 850aaaaaaaaaaaaaaaaaaaa|*2 851aaaaaaaaa^a{1:¬} | 852| 853]] ) 854feed ( '0' ) 855screen : expect ( [[ 856^aaaaaaaaaaaaaaaaaaaa| 857aaaaaaaaaaaaaaaaaaaa|*3 858| 859]] ) 860end ) 861 862it ( "'listchar' in visual mode" , function () 863screen : add_extra_attr_ids { 864[ 100 ] ={ 865foreground =Screen . colors . Blue1 , 866bold =true , 867background =Screen . colors . LightGray , 868} , 869[ 101 ] ={ foreground =Screen . colors . Red , background =Screen . colors . Grey90 } , 870[ 102 ] ={ foreground =Screen . colors . Blue1 , bold =true , background =Screen . colors . Grey90 } , 871[ 103 ] ={ foreground =Screen . colors . Red , background =Screen . colors . LightGray } , 872} 873command ( 'highlight clear ModeMsg' ) 874command ( 'highlight Whitespace guifg=#FF0000' ) 875command ( 'set cursorline' ) 876command ( 'set tabstop=8' ) 877command ( 'set nowrap' ) 878command ( 'set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list' ) 879feed ( 'i\t abcd <cr>\t abcd Lorem ipsum dolor sit amet<cr><esc>kkk0' ) 880screen : expect ( [[ 881{101:^>-------.}{21:abcd}{101:*}{102:¬}{21: }| 882{19:>-------.}abcd{19:.}Lorem{1:>}| 883{1:¬} | 884{1:~ }| 885| 886]] ) 887feed ( 'lllvj' ) 888screen : expect ( [[ 889{19:>-------.}a{17:bcd}{103:*}{100:¬} | 890{103:>-------.}{17:a^b}cd{19:.}Lorem{1:>}| 891{1:¬} | 892{1:~ }| 893-- VISUAL -- | 894]] ) 895feed ( '<esc>V' ) 896screen : expect ( [[ 897{19:>-------.}abcd{19:*}{1:¬} | 898{103:>-------.}{17:a^bcd}{103:.}{17:Lorem}{1:>}| 899{1:¬} | 900{1:~ }| 901-- VISUAL LINE -- | 902]] ) 903feed ( '<esc>$' ) 904screen : expect ( [[ 905{1:<} | 906{102:<}{21:r}{101:.}{21:sit}{101:.}{21:ame^t}{102:¬}{21: }| 907{1:<} | 908{1:~ }| 909| 910]] ) 911end ) 912 913it ( "'cursorline' with :match" , function () 914screen : add_extra_attr_ids { 915[ 100 ] ={ foreground =Screen . colors . Lime , background =Screen . colors . Red } , 916} 917feed_command ( 'highlight clear ModeMsg' ) 918feed_command ( 'highlight Whitespace guifg=#FF0000' ) 919feed_command ( 'highlight Error guifg=#00FF00' ) 920feed_command ( 'set nowrap' ) 921feed ( 'ia \t bc \t <esc>' ) 922screen : expect ( [[ 923a bc ^ | 924{1:~ }|*3 925| 926]] ) 927feed_command ( 'set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list' ) 928screen : expect ( [[ 929a{19:.>-----.}bc{19:*>---*^*}{1:¬} | 930{1:~ }|*3 931| 932]] ) 933feed_command ( 'match Error /\\s\\+$/' ) 934screen : expect ( [[ 935a{19:.>-----.}bc{100:*>---*^*}{1:¬} | 936{1:~ }|*3 937| 938]] ) 939end ) 940end ) 941 942describe ( 'CursorLine and CursorLineNr highlights' , function () 943before_each ( clear ) 944 945it ( 'overridden by Error, ColorColumn if fg not set' , function () 946local screen =Screen . new ( 50 , 5 ) 947screen : add_extra_attr_ids { 948[ 100 ] ={ background =Screen . colors . LightRed } , 949[ 101 ] ={ foreground =Screen . colors . SlateBlue , background =Screen . colors . Grey90 } , 950} 951 952command ( 'filetype on' ) 953command ( 'syntax on' ) 954command ( 'set cursorline ft=json' ) 955feed ( 'i{<cr>"a" : abc // 10;<cr>}<cr><esc>' ) 956screen : expect ( [[ 957{16:{} | 958"{15:a}" : {9:abc} {9:// 10;} | 959{16:}} | 960{21:^ }| 961| 962]] ) 963 964command ( 'set colorcolumn=3' ) 965feed ( 'i <esc>' ) 966screen : expect ( [[ 967{16:{} {100: } | 968"{15:a}{100:"} : {9:abc} {9:// 10;} | 969{16:}} {100: } | 970{21: ^ }{100: }{21: }| 971| 972]] ) 973end ) 974 975it ( "overridden by NonText in 'showbreak' characters" , function () 976local screen =Screen . new ( 20 , 5 ) 977screen : add_extra_attr_ids { 978[ 100 ] ={ foreground =Screen . colors . Yellow1 } , 979[ 101 ] ={ foreground =Screen . colors . Yellow1 , background =Screen . colors . Blue } , 980[ 102 ] ={ foreground =Screen . colors . Grey0 , background =Screen . colors . Grey100 } , 981[ 103 ] ={ foreground =Screen . colors . Yellow1 , background =Screen . colors . Grey100 } , 982} 983 984feed_command ( 'set wrap cursorline' ) 985feed_command ( 'set showbreak=>>>' ) 986feed_command ( 'highlight clear NonText' ) 987feed_command ( 'highlight clear CursorLine' ) 988feed_command ( 'highlight NonText guifg=Yellow guibg=Blue gui=NONE' ) 989feed_command ( 'highlight CursorLine guifg=Black guibg=White gui=NONE' ) 990 991feed ( '30iø<esc>o<esc>30ia<esc>' ) 992screen : expect ( [[ 993øøøøøøøøøøøøøøøøøøøø| 994{101:>>>}øøøøøøøøøø | 995{102:aaaaaaaaaaaaaaaaaaaa}| 996{101:>>>}{102:aaaaaaaaa^a }| 997| 998]] ) 999feed ( 'k' ) 1000screen : expect ( [[ 1001{102:øøøøøøøøøøøøøøøøøøøø}| 1002{101:>>>}{102:øøøøøøøøø^ø }| 1003aaaaaaaaaaaaaaaaaaaa| 1004{101:>>>}aaaaaaaaaa | 1005| 1006]] ) 1007feed_command ( 'highlight NonText guibg=NONE' ) 1008screen : expect ( [[ 1009{102:øøøøøøøøøøøøøøøøøøøø}| 1010{103:>>>}{102:øøøøøøøøø^ø }| 1011aaaaaaaaaaaaaaaaaaaa| 1012{100:>>>}aaaaaaaaaa | 1013| 1014]] ) 1015feed_command ( 'set nocursorline' ) 1016screen : expect ( [[ 1017øøøøøøøøøøøøøøøøøøøø| 1018{100:>>>}øøøøøøøøø^ø | 1019aaaaaaaaaaaaaaaaaaaa| 1020{100:>>>}aaaaaaaaaa | 1021:set nocursorline | 1022]] ) 1023end ) 1024 1025it ( "'cursorlineopt' screenline" , function () 1026local screen =Screen . new ( 20 , 5 ) 1027screen : add_extra_attr_ids { 1028[ 100 ] ={ foreground =Screen . colors . Yellow } , 1029[ 101 ] ={ foreground =Screen . colors . Red , background =Screen . colors . WebGreen } , 1030[ 102 ] ={ foreground =Screen . colors . Black , background =Screen . colors . Grey100 } , 1031[ 103 ] ={ foreground =Screen . colors . WebGreen , background =Screen . colors . Red } , 1032} 1033 1034command ( 'set wrap cursorline cursorlineopt=screenline' ) 1035command ( 'set showbreak=>>>' ) 1036command ( 'highlight clear NonText' ) 1037command ( 'highlight clear CursorLine' ) 1038command ( 'highlight NonText guifg=Yellow gui=NONE' ) 1039command ( 'highlight LineNr guifg=Red guibg=Green gui=NONE' ) 1040command ( 'highlight CursorLine guifg=Black guibg=White gui=NONE' ) 1041command ( 'highlight CursorLineNr guifg=Green guibg=Red gui=NONE' ) 1042 1043feed ( '30iø<esc>o<esc>30ia<esc>' ) 1044 1045-- CursorLine should not apply to 'showbreak' when 'cursorlineopt' contains "screenline" 1046screen : expect ( [[ 1047øøøøøøøøøøøøøøøøøøøø| 1048{100:>>>}øøøøøøøøøø | 1049aaaaaaaaaaaaaaaaaaaa| 1050{100:>>>}{102:aaaaaaaaa^a }| 1051| 1052]] ) 1053feed ( 'gk' ) 1054screen : expect ( [[ 1055øøøøøøøøøøøøøøøøøøøø| 1056{100:>>>}øøøøøøøøøø | 1057{102:aaaaaaaaaaaa^aaaaaaaa}| 1058{100:>>>}aaaaaaaaaa | 1059| 1060]] ) 1061feed ( 'k' ) 1062screen : expect ( [[ 1063{102:øøøøøøøøøøøø^øøøøøøøø}| 1064{100:>>>}øøøøøøøøøø | 1065aaaaaaaaaaaaaaaaaaaa| 1066{100:>>>}aaaaaaaaaa | 1067| 1068]] ) 1069 1070-- CursorLineNr should not apply to line number when 'cursorlineopt' does not contain "number" 1071command ( 'set relativenumber numberwidth=2' ) 1072screen : expect ( [[ 1073{101:0 }{102:øøøøøøøøøøøø^øøøøøø}| 1074{101: }{100:>>>}øøøøøøøøøøøø | 1075{101:1 }aaaaaaaaaaaaaaaaaa| 1076{101: }{100:>>>}aaaaaaaaaaaa | 1077| 1078]] ) 1079 1080-- CursorLineNr should apply to line number when 'cursorlineopt' contains "number" 1081command ( 'set cursorlineopt+=number' ) 1082screen : expect ( [[ 1083{103:0 }{102:øøøøøøøøøøøø^øøøøøø}| 1084{101: }{100:>>>}øøøøøøøøøøøø | 1085{101:1 }aaaaaaaaaaaaaaaaaa| 1086{101: }{100:>>>}aaaaaaaaaaaa | 1087| 1088]] ) 1089feed ( 'gj' ) 1090screen : expect ( [[ 1091{103:0 }øøøøøøøøøøøøøøøøøø| 1092{101: }{100:>>>}{102:øøøøøøøøø^øøø }| 1093{101:1 }aaaaaaaaaaaaaaaaaa| 1094{101: }{100:>>>}aaaaaaaaaaaa | 1095| 1096]] ) 1097feed ( 'gj' ) 1098screen : expect ( [[ 1099{101:1 }øøøøøøøøøøøøøøøøøø| 1100{101: }{100:>>>}øøøøøøøøøøøø | 1101{103:0 }{102:aaaaaaaaaaaa^aaaaaa}| 1102{101: }{100:>>>}aaaaaaaaaaaa | 1103| 1104]] ) 1105feed ( 'gj' ) 1106screen : expect ( [[ 1107{101:1 }øøøøøøøøøøøøøøøøøø| 1108{101: }{100:>>>}øøøøøøøøøøøø | 1109{103:0 }aaaaaaaaaaaaaaaaaa| 1110{101: }{100:>>>}{102:aaaaaaaaa^aaa }| 1111| 1112]] ) 1113 1114-- updated in Insert mode 1115feed ( 'I' ) 1116screen : expect ( [[ 1117{101:1 }øøøøøøøøøøøøøøøøøø| 1118{101: }{100:>>>}øøøøøøøøøøøø | 1119{103:0 }{102:^aaaaaaaaaaaaaaaaaa}| 1120{101: }{100:>>>}aaaaaaaaaaaa | 1121{5:-- INSERT --} | 1122]] ) 1123 1124feed ( '<Esc>gg' ) 1125screen : expect ( [[ 1126{103:0 }{102:^øøøøøøøøøøøøøøøøøø}| 1127{101: }{100:>>>}øøøøøøøøøøøø | 1128{101:1 }aaaaaaaaaaaaaaaaaa| 1129{101: }{100:>>>}aaaaaaaaaaaa | 1130| 1131]] ) 1132end ) 1133 1134-- oldtest: Test_cursorline_screenline_resize() 1135it ( "'cursorlineopt' screenline is updated on window resize" , function () 1136local screen =Screen . new ( 75 , 8 ) 1137exec ( [[ 113850vnew 1139call setline(1, repeat('xyz ', 30)) 1140setlocal number cursorline cursorlineopt=screenline 1141normal! $ 1142]] ) 1143screen : expect ( [[ 1144{8: 1 }xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xy│ | 1145{8: }z xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz │{1:~ }| 1146{8: }{21:xyz xyz xyz xyz xyz xyz xyz^ }│{1:~ }| 1147{1:~ }│{1:~ }|*3 1148{3:[No Name] [+] }{2:[No Name] }| 1149| 1150]] ) 1151command ( 'vertical resize -4' ) 1152screen : expect ( [[ 1153{8: 1 }xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xy│ | 1154{8: }z xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz │{1:~ }| 1155{8: }{21:xyz xyz xyz xyz xyz xyz xyz xyz xyz^ }│{1:~ }| 1156{1:~ }│{1:~ }|*3 1157{3:[No Name] [+] }{2:[No Name] }| 1158| 1159]] ) 1160command ( 'set cpoptions+=n' ) 1161screen : expect ( [[ 1162{8: 1 }xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xy│ | 1163z xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz │{1:~ }| 1164{21:xyz xyz xyz xyz xyz xyz xyz xyz^ }│{1:~ }| 1165{1:~ }│{1:~ }|*3 1166{3:[No Name] [+] }{2:[No Name] }| 1167| 1168]] ) 1169end ) 1170 1171-- oldtest: Test_cursorline_screenline_update() 1172it ( "'cursorlineopt' screenline is updated on various movements" , function () 1173local screen =Screen . new ( 75 , 8 ) 1174exec ( [[ 1175func TestRetab() 1176let w = winwidth(0) 1177call cursor([1, w + 1, 0, w + 1]) 1178call line('w0') 1179retab 8 1180endfunc 1181 1182call setline(1, repeat('xyz ', 30)) 1183set cursorline cursorlineopt=screenline tabstop=8 1184inoremap <F2> <Cmd>call cursor(1, 1)<CR> 1185inoremap <F3> <Cmd>call TestRetab()<CR> 1186]] ) 1187 1188feed ( 'A' ) 1189screen : expect ( [[ 1190xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz| 1191{21: xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz ^ }| 1192{1:~ }|*5 1193{5:-- INSERT --} | 1194]] ) 1195feed ( '<F2>' ) 1196screen : expect ( [[ 1197{21:^xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz}| 1198xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz | 1199{1:~ }|*5 1200{5:-- INSERT --} | 1201]] ) 1202feed ( '<F3>' ) 1203screen : expect ( [[ 1204xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz| 1205{21:^ xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz xyz }| 1206{1:~ }|*5 1207{5:-- INSERT --} | 1208]] ) 1209feed ( '<Esc>' ) 1210end ) 1211 1212-- oldtest: Test_cursorline_after_yank() 1213it ( 'always updated. vim-patch:8.1.0849' , function () 1214local screen =Screen . new ( 50 , 5 ) 1215screen : add_extra_attr_ids { 1216[ 100 ] ={ background =Screen . colors . LightRed } , 1217[ 101 ] ={ foreground =Screen . colors . SlateBlue , background =Screen . colors . Grey90 } , 1218} 1219command ( 'set cursorline relativenumber' ) 1220command ( 'call setline(1, ["","1","2","3",""])' ) 1221feed ( 'Gy3k' ) 1222screen : expect ( [[ 1223{15: 0 }{21:^1 }| 1224{8: 1 }2 | 1225{8: 2 }3 | 1226{8: 3 } | 12274 lines yanked | 1228]] ) 1229feed ( 'jj' ) 1230screen : expect ( [[ 1231{8: 2 }1 | 1232{8: 1 }2 | 1233{15: 0 }{21:^3 }| 1234{8: 1 } | 12354 lines yanked | 1236]] ) 1237end ) 1238 1239-- oldtest: Test_cursorline_with_visualmode() 1240it ( 'with visual area. vim-patch:8.1.1001' , function () 1241local screen =Screen . new ( 50 , 5 ) 1242screen : add_extra_attr_ids { 1243[ 100 ] ={ foreground =Screen . colors . SlateBlue , background =Screen . colors . Grey90 } , 1244[ 101 ] ={ background =Screen . colors . LightRed } , 1245} 1246command ( 'set cursorline' ) 1247command ( 'call setline(1, repeat(["abc"], 50))' ) 1248feed ( 'V<C-f>zbkkjk' ) 1249screen : expect ( [[ 1250{17:abc} | 1251{17:^abc} | 1252abc |*2 1253{5:-- VISUAL LINE --} | 1254]] ) 1255end ) 1256 1257-- oldtest: Test_cursorline_callback() 1258it ( 'is updated if cursor is moved up from timer vim-patch:8.2.4591' , function () 1259local screen =Screen . new ( 50 , 8 ) 1260exec ( [[ 1261call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd']) 1262set cursorline 1263call cursor(4, 1) 1264 1265func Func(timer) 1266call cursor(2, 1) 1267endfunc 1268]] ) 1269screen : expect ( [[ 1270aaaaa | 1271bbbbb | 1272ccccc | 1273{21:^ddddd }| 1274{1:~ }|*3 1275| 1276]] ) 1277command ( [[call timer_start(300, 'Func')]] ) 1278screen : expect_unchanged ( false , 100 ) 1279screen : expect ( [[ 1280aaaaa | 1281{21:^bbbbb }| 1282ccccc | 1283ddddd | 1284{1:~ }|*3 1285| 1286]] ) 1287end ) 1288 1289it ( 'with split windows in diff mode' , function () 1290local screen =Screen . new ( 50 , 12 ) 1291screen : add_extra_attr_ids { 1292[ 100 ] ={ background =Screen . colors . Plum1 , underline =true } , 1293[ 101 ] ={ background =Screen . colors . Red1 , bold =true , underline =true } , 1294} 1295 1296command ( 'hi CursorLine ctermbg=red ctermfg=white guibg=red guifg=white' ) 1297command ( 'set cursorline' ) 1298feed ( 'iline 1 some text<cr>line 2 more text<cr>extra line!<cr>extra line!<cr>last line ...<cr>' ) 1299feed ( '<esc>gg' ) 1300command ( 'vsplit' ) 1301command ( 'enew' ) 1302feed ( 1303'iline 1 some text<cr>line 2 moRe text!<cr>extra line!<cr>extra line!<cr>extra line!<cr>last line ...<cr>' 1304) 1305feed ( '<esc>gg' ) 1306command ( 'windo diffthis' ) 1307screen : expect ( [[ 1308{7: }{9:line 1 some text }│{7: }{9:^line 1 some text }| 1309{7: }{4:line 2 mo}{27:R}{4:e text}{27:!}{4: }│{7: }{4:line 2 mo}{27:r}{4:e text }| 1310{7: }{22:extra line! }│{7: }{23:----------------------}| 1311{7: }extra line! │{7: }extra line! |*2 1312{7: }last line ... │{7: }last line ... | 1313{7: } │{7: } | 1314{1:~ }│{1:~ }|*3 1315{2:[No Name] [+] }{3:[No Name] [+] }| 1316| 1317]] ) 1318feed ( 'jjjjj' ) 1319screen : expect ( [[ 1320{7: }line 1 some text │{7: }line 1 some text | 1321{7: }{4:line 2 mo}{27:R}{4:e text}{27:!}{4: }│{7: }{4:line 2 mo}{27:r}{4:e text }| 1322{7: }{22:extra line! }│{7: }{23:----------------------}| 1323{7: }extra line! │{7: }extra line! |*2 1324{7: }last line ... │{7: }last line ... | 1325{7: }{9: }│{7: }{9:^ }| 1326{1:~ }│{1:~ }|*3 1327{2:[No Name] [+] }{3:[No Name] [+] }| 1328| 1329]] ) 1330 1331-- CursorLine with fg=NONE is "low-priority". 1332-- Rendered as underline in a diff-line. #9028 1333command ( 'hi CursorLine ctermbg=red ctermfg=NONE guibg=red guifg=NONE' ) 1334feed ( 'kkkk' ) 1335screen : expect ( [[ 1336{7: }line 1 some text │{7: }line 1 some text | 1337{7: }{100:line 2 mo}{101:R}{100:e text}{101:!}{100: }│{7: }{100:^line 2 mo}{101:r}{100:e text }| 1338{7: }{22:extra line! }│{7: }{23:----------------------}| 1339{7: }extra line! │{7: }extra line! |*2 1340{7: }last line ... │{7: }last line ... | 1341{7: } │{7: } | 1342{1:~ }│{1:~ }|*3 1343{2:[No Name] [+] }{3:[No Name] [+] }| 1344| 1345]] ) 1346end ) 1347 1348-- oldtest: Test_diff_with_cursorline_number() 1349it ( 'CursorLineNr shows correctly just below filler lines' , function () 1350local screen =Screen . new ( 50 , 12 ) 1351screen : add_extra_attr_ids { 1352[ 100 ] ={ foreground =Screen . colors . Black , bold =true , background =Screen . colors . Grey100 } , 1353} 1354 1355command ( 'hi CursorLine guibg=red guifg=white' ) 1356command ( 'hi CursorLineNr guibg=white guifg=black gui=bold' ) 1357command ( 'set cursorline number' ) 1358command ( 'call setline(1, ["baz", "foo", "foo", "bar"])' ) 1359feed ( '2gg0' ) 1360command ( 'vnew' ) 1361command ( 'call setline(1, ["foo", "foo", "bar"])' ) 1362command ( 'windo diffthis' ) 1363command ( '1wincmd w' ) 1364screen : expect ( [[ 1365{7: }{8: }{23:-------------------}│{7: }{8: 1 }{22:baz }| 1366{7: }{100: 1 }{9:^foo }│{7: }{100: 2 }{9:foo }| 1367{7: }{8: 2 }foo │{7: }{8: 3 }foo | 1368{7: }{8: 3 }bar │{7: }{8: 4 }bar | 1369{1:~ }│{1:~ }|*6 1370{3:[No Name] [+] }{2:[No Name] [+] }| 1371| 1372]] ) 1373command ( 'set cursorlineopt=number' ) 1374screen : expect ( [[ 1375{7: }{8: }{23:-------------------}│{7: }{8: 1 }{22:baz }| 1376{7: }{100: 1 }^foo │{7: }{100: 2 }{9:foo }| 1377{7: }{8: 2 }foo │{7: }{8: 3 }foo | 1378{7: }{8: 3 }bar │{7: }{8: 4 }bar | 1379{1:~ }│{1:~ }|*6 1380{3:[No Name] [+] }{2:[No Name] [+] }| 1381| 1382]] ) 1383end ) 1384 1385it ( 'CursorLine overlays hl group linked to Normal' , function () 1386local screen =Screen . new ( 50 , 12 ) 1387screen : add_extra_attr_ids ( { 1388[ 101 ] ={ background =Screen . colors . Grey90 , foreground =Screen . colors . Grey100 } , 1389[ 102 ] ={ background =Screen . colors . DarkGray , foreground =Screen . colors . WebGreen } , 1390} ) 1391command ( 'hi Normal guibg=black guifg=white' ) 1392command ( 'hi def link Test Normal' ) 1393feed ( 'ifoo bar<ESC>' ) 1394feed ( ':call matchadd("Test", "bar")<cr>' ) 1395command ( 'set cursorline' ) 1396screen : expect ( [[ 1397{21:foo }{101:ba^r}{21: }| 1398{1:~ }|*10 1399:call matchadd("Test", "bar") | 1400]] ) 1401api . nvim_buf_set_lines ( 0 , 0 , - 1 , false , { 'aaaaa' , 'bbbbb' } ) 1402command ( 'hi AAA guifg=Green guibg=DarkGrey ctermfg=Green ctermbg=DarkGrey' ) 1403fn . matchadd ( 'AAA' , 'aaaaa' ) 1404command ( 'setlocal winhighlight=Normal:NormalFloat' ) 1405screen : expect ( [[ 1406{102:aaaa^a}{21: }| 1407{4:bbbbb }| 1408{11:~ }|*9 1409:call matchadd("Test", "bar") | 1410]] ) 1411end ) 1412end ) 1413 1414describe ( 'CursorColumn highlight' , function () 1415local screen 1416before_each ( function () 1417clear () 1418screen =Screen . new ( 50 , 8 ) 1419screen : add_extra_attr_ids { 1420[ 100 ] ={ background =Screen . colors . Blue1 } , 1421} 1422end ) 1423 1424it ( 'is updated when pressing "i" on a TAB character' , function () 1425exec ( [[ 1426call setline(1, ['123456789', "a\tb"]) 1427set cursorcolumn 1428call cursor(2, 2) 1429]] ) 1430screen : expect ( [[ 14311234567{21:8}9 | 1432a ^ b | 1433{1:~ }|*5 1434| 1435]] ) 1436feed ( 'i' ) 1437screen : expect ( [[ 14381{21:2}3456789 | 1439a^ b | 1440{1:~ }|*5 1441{5:-- INSERT --} | 1442]] ) 1443feed ( '<C-O>' ) 1444screen : expect ( [[ 14451234567{21:8}9 | 1446a ^ b | 1447{1:~ }|*5 1448{5:-- (insert) --} | 1449]] ) 1450feed ( 'i' ) 1451screen : expect ( [[ 14521{21:2}3456789 | 1453a^ b | 1454{1:~ }|*5 1455{5:-- INSERT --} | 1456]] ) 1457end ) 1458 1459-- oldtest: Test_cursorcolumn_virtualedit() 1460it ( 'is correct with operator on empty line and virtualedit' , function () 1461exec ( [[ 1462set virtualedit=all 1463set cursorcolumn 1464call setline(1, ['', '', '']) 1465call cursor(3, 1) 1466]] ) 1467screen : expect ( [[ 1468{21: } |*2 1469^ | 1470{1:~ }|*4 1471| 1472]] ) 1473feed ( '<Del>' ) 1474screen : expect_unchanged () 1475end ) 1476 1477-- oldtest: Test_cursorcolumn_callback() 1478it ( 'is updated if cursor is moved from timer' , function () 1479exec ( [[ 1480call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd']) 1481set cursorcolumn 1482call cursor(4, 5) 1483 1484func Func(timer) 1485call cursor(1, 1) 1486endfunc 1487]] ) 1488screen : expect ( [[ 1489aaaa{21:a} | 1490bbbb{21:b} | 1491cccc{21:c} | 1492dddd^d | 1493{1:~ }|*3 1494| 1495]] ) 1496command ( [[call timer_start(300, 'Func')]] ) 1497screen : expect_unchanged ( false , 100 ) 1498screen : expect ( [[ 1499^aaaaa | 1500{21:b}bbbb | 1501{21:c}cccc | 1502{21:d}dddd | 1503{1:~ }|*3 1504| 1505]] ) 1506end ) 1507 1508it ( 'is not shown on current line with virtualedit' , function () 1509exec ( [[ 1510hi! CursorColumn guibg=Red 1511hi! CursorLine guibg=Blue 1512set virtualedit=all cursorline cursorcolumn 1513]] ) 1514insert ( 'line 1\nline 2\nline 3' ) 1515feed ( 'k' ) 1516screen : expect ( [[ 1517line {30:1} | 1518{100:line ^2 }| 1519line {30:3} | 1520{1:~ }|*4 1521| 1522]] ) 1523feed ( 'l' ) 1524screen : expect ( [[ 1525line 1{30: } | 1526{100:line 2^ }| 1527line 3{30: } | 1528{1:~ }|*4 1529| 1530]] ) 1531feed ( 'l' ) 1532screen : expect ( [[ 1533line 1 {30: } | 1534{100:line 2 ^ }| 1535line 3 {30: } | 1536{1:~ }|*4 1537| 1538]] ) 1539feed ( 'l' ) 1540screen : expect ( [[ 1541line 1 {30: } | 1542{100:line 2 ^ }| 1543line 3 {30: } | 1544{1:~ }|*4 1545| 1546]] ) 1547end ) 1548 1549it ( 'is updated with completion active #39153' , function () 1550command ( 'set autocomplete cursorcolumn' ) 1551feed ( 'iasdf<CR>' ) 1552screen : expect ( [[ 1553{21:a}sdf | 1554^ | 1555{1:~ }|*5 1556{5:-- INSERT --} | 1557]] ) 1558feed ( 'a' ) 1559screen : expect ( [[ 1560a{21:s}df | 1561a^ | 1562{4:asdf }{1: }| 1563{1:~ }|*4 1564{5:-- INSERT --} | 1565]] ) 1566feed ( 's' ) 1567screen : expect ( [[ 1568as{21:d}f | 1569as^ | 1570{4:asdf }{1: }| 1571{1:~ }|*4 1572{5:-- INSERT --} | 1573]] ) 1574feed ( 'd' ) 1575screen : expect ( [[ 1576asd{21:f} | 1577asd^ | 1578{4:asdf }{1: }| 1579{1:~ }|*4 1580{5:-- INSERT --} | 1581]] ) 1582feed ( 'f' ) 1583screen : expect ( [[ 1584asdf{21: } | 1585asdf^ | 1586{4:asdf }{1: }| 1587{1:~ }|*4 1588{5:-- INSERT --} | 1589]] ) 1590feed ( 'g' ) 1591screen : expect ( [[ 1592asdf {21: } | 1593asdfg^ | 1594{1:~ }|*5 1595{5:-- INSERT --} | 1596]] ) 1597feed ( ' ' ) 1598screen : expect ( [[ 1599asdf {21: } | 1600asdfg ^ | 1601{1:~ }|*5 1602{5:-- INSERT --} | 1603]] ) 1604feed ( '<BS>' ) 1605screen : expect ( [[ 1606asdf {21: } | 1607asdfg^ | 1608{1:~ }|*5 1609{5:-- INSERT --} | 1610]] ) 1611feed ( '<BS>' ) 1612screen : expect ( [[ 1613asdf{21: } | 1614asdf^ | 1615{4:asdf }{1: }| 1616{1:~ }|*4 1617{5:-- INSERT --} | 1618]] ) 1619feed ( '<BS>' ) 1620screen : expect ( [[ 1621asd{21:f} | 1622asd^ | 1623{4:asdf }{1: }| 1624{1:~ }|*4 1625{5:-- INSERT --} | 1626]] ) 1627feed ( 'h' ) 1628screen : expect ( [[ 1629asdf{21: } | 1630asdh^ | 1631{1:~ }|*5 1632{5:-- INSERT --} | 1633]] ) 1634feed ( '<Esc>' ) 1635screen : expect ( [[ 1636asd{21:f} | 1637asd^h | 1638{1:~ }|*5 1639| 1640]] ) 1641end ) 1642end ) 1643 1644describe ( 'ColorColumn highlight' , function () 1645local screen 1646 1647before_each ( function () 1648clear () 1649screen =Screen . new ( 40 , 15 ) 1650screen : add_extra_attr_ids { 1651[ 100 ] ={ foreground =Screen . colors . Red , background =Screen . colors . Grey90 } , 1652[ 101 ] ={ background =Screen . colors . LightRed } , 1653[ 102 ] ={ foreground =Screen . colors . Blue1 , bold =true , background =Screen . colors . LightRed } , 1654} 1655end ) 1656 1657-- oldtest: Test_colorcolumn() 1658it ( 'when entering a buffer vim-patch:8.1.2073' , function () 1659exec ( [[ 1660set nohidden 1661split 1662edit X 1663call setline(1, ["1111111111","22222222222","3333333333"]) 1664set nomodified 1665set colorcolumn=3,9 1666set number cursorline cursorlineopt=number 1667wincmd w 1668buf X 1669]] ) 1670screen : expect ( [[ 1671{15: 1 }11{101:1}11111{101:1}1 | 1672{8: 2 }22{101:2}22222{101:2}22 | 1673{8: 3 }33{101:3}33333{101:3}3 | 1674{1:~ }|*3 1675{2:X }| 1676{15: 1 }^11{101:1}11111{101:1}1 | 1677{8: 2 }22{101:2}22222{101:2}22 | 1678{8: 3 }33{101:3}33333{101:3}3 | 1679{1:~ }|*3 1680{3:X }| 1681| 1682]] ) 1683end ) 1684 1685-- oldtest: Test_colorcolumn_bri() 1686it ( "in 'breakindent' vim-patch:8.2.1689" , function () 1687exec ( [[ 1688call setline(1, 'The quick brown fox jumped over the lazy dogs') 1689set co=40 linebreak bri briopt=shift:2 cc=40,41,43 1690]] ) 1691screen : expect ( [[ 1692^The quick brown fox jumped over the {101: }| 1693{101: } {101:l}azy dogs | 1694{1:~ }|*12 1695| 1696]] ) 1697end ) 1698 1699-- oldtest: Test_colorcolumn_sbr() 1700it ( "in 'showbreak' vim-patch:8.2.1689" , function () 1701exec ( [[ 1702call setline(1, 'The quick brown fox jumped over the lazy dogs') 1703set co=40 showbreak=+++>\\ cc=40,41,43 1704]] ) 1705screen : expect ( [[ 1706^The quick brown fox jumped over the laz{101:y}| 1707{102:+}{1:+}{102:+}{1:>\} dogs | 1708{1:~ }|*12 1709| 1710]] ) 1711end ) 1712 1713it ( 'is combined with low-priority CursorLine highlight #23016' , function () 1714screen : try_resize ( 40 , 2 ) 1715command ( 'set colorcolumn=30 cursorline' ) 1716screen : expect ( [[ 1717{21:^ }{101: }{21: }| 1718| 1719]] ) 1720command ( 'hi clear ColorColumn' ) 1721screen : expect ( [[ 1722{21:^ }| 1723| 1724]] ) 1725command ( 'hi ColorColumn guifg=Red' ) 1726screen : expect ( [[ 1727{21:^ }{100: }{21: }| 1728| 1729]] ) 1730end ) 1731end ) 1732 1733describe ( 'MsgSeparator highlight and msgsep fillchar' , function () 1734local screen 1735before_each ( function () 1736clear () 1737screen =Screen . new ( 50 , 5 ) 1738screen : set_default_attr_ids ( { 1739[ 1 ] ={ bold =true , foreground =Screen . colors . Blue } , 1740[ 2 ] ={ bold =true , reverse =true } , 1741[ 3 ] ={ bold =true , foreground =Screen . colors . SeaGreen4 } , 1742[ 4 ] ={ background =Screen . colors . Cyan , bold =true , reverse =true } , 1743[ 5 ] ={ bold =true , background =Screen . colors . Magenta } , 1744[ 6 ] ={ background =Screen . colors . WebGray } , 1745[ 7 ] ={ 1746background =Screen . colors . WebGray , 1747bold =true , 1748foreground =Screen . colors . SeaGreen4 , 1749} , 1750[ 8 ] ={ foreground =Screen . colors . Grey0 , background =Screen . colors . Gray60 } , 1751[ 9 ] ={ foreground =Screen . colors . Grey40 , background =Screen . colors . Gray60 } , 1752[ 10 ] ={ foreground =tonumber ( '0x000019' ), background =Screen . colors . Gray60 } , 1753[ 11 ] ={ background =Screen . colors . Gray60 , bold =true , foreground =tonumber ( '0x666699' ) } , 1754[ 12 ] ={ background =Screen . colors . Gray60 , bold =true , foreground =tonumber ( '0x297d4e' ) } , 1755[ 13 ] ={ background =tonumber ( '0xff4cff' ), bold =true , foreground =tonumber ( '0xb200ff' ) } , 1756} ) 1757end ) 1758 1759it ( 'works' , function () 1760-- defaults 1761feed_command ( 'ls' ) 1762screen : expect ( [[ 1763| 1764{2: }| 1765:ls | 17661 %a "[No Name]" line 1 | 1767{3:Press ENTER or type command to continue}^ | 1768]] ) 1769feed ( '<cr>' ) 1770 1771feed_command ( 'set fillchars+=msgsep:-' ) 1772feed_command ( 'ls' ) 1773screen : expect ( [[ 1774| 1775{2:--------------------------------------------------}| 1776:ls | 17771 %a "[No Name]" line 1 | 1778{3:Press ENTER or type command to continue}^ | 1779]] ) 1780 1781-- linked to StatusLine per default 1782feed_command ( 'hi StatusLine guibg=Cyan' ) 1783feed_command ( 'ls' ) 1784screen : expect ( [[ 1785| 1786{4:--------------------------------------------------}| 1787:ls | 17881 %a "[No Name]" line 1 | 1789{3:Press ENTER or type command to continue}^ | 1790]] ) 1791 1792-- but can be unlinked 1793feed_command ( 'hi clear MsgSeparator' ) 1794feed_command ( 'hi MsgSeparator guibg=Magenta gui=bold' ) 1795feed_command ( 'ls' ) 1796screen : expect ( [[ 1797| 1798{5:--------------------------------------------------}| 1799:ls | 18001 %a "[No Name]" line 1 | 1801{3:Press ENTER or type command to continue}^ | 1802]] ) 1803end ) 1804 1805it ( 'and MsgArea' , function () 1806feed_command ( 'hi MsgArea guibg=Gray' ) 1807screen : expect { 1808grid =[[ 1809^ | 1810{1:~ }|*3 1811{6: }| 1812]] , 1813} 1814feed ( ':ls' ) 1815screen : expect { 1816grid =[[ 1817| 1818{1:~ }|*3 1819{6::ls^ }| 1820]] , 1821} 1822feed ( ':<cr>' ) 1823screen : expect { 1824grid =[[ 1825| 1826{2: }| 1827{6::ls: }| 1828{6: 1 %a "[No Name]" line 1 }| 1829{7:Press ENTER or type command to continue}{6:^ }| 1830]] , 1831} 1832 1833-- support madness^Wblending of message "overlay" 1834feed_command ( 'hi MsgArea blend=20' ) 1835feed_command ( 'hi clear MsgSeparator' ) 1836feed_command ( 'hi MsgSeparator blend=30 guibg=Magenta' ) 1837screen : expect { 1838grid =[[ 1839^ | 1840{1:~ }|*3 1841{8::hi}{9: }{8:MsgSeparator}{9: }{8:blend=30}{9: }{8:guibg=Magenta}{9: }| 1842]] , 1843} 1844feed ( ':ls' ) 1845screen : expect { 1846grid =[[ 1847| 1848{1:~ }|*3 1849{8::ls}{9:^ }| 1850]] , 1851} 1852feed ( '<cr>' ) 1853screen : expect { 1854grid =[[ 1855| 1856{13:~ }| 1857{10::ls}{11: }| 1858{11:~ }{10:1}{11: }{10:%a}{11: }{10:"[No}{11: }{10:Name]"}{11: }{10:line}{11: }{10:1}{11: }| 1859{12:Press}{9: }{12:ENTER}{9: }{12:or}{9: }{12:type}{9: }{12:command}{9: }{12:to}{9: }{12:continue}{9:^ }| 1860]] , 1861} 1862end ) 1863end ) 1864 1865describe ( "'winhighlight' highlight" , function () 1866local screen 1867 1868before_each ( function () 1869clear () 1870screen =Screen . new ( 20 , 8 ) 1871screen : set_default_attr_ids { 1872[ 0 ] ={ bold =true , foreground =Screen . colors . Blue } , 1873[ 1 ] ={ background =Screen . colors . DarkBlue } , 1874[ 2 ] ={ background =Screen . colors . DarkBlue , bold =true , foreground =Screen . colors . Blue1 } , 1875[ 3 ] ={ bold =true , reverse =true } , 1876[ 4 ] ={ reverse =true } , 1877[ 5 ] ={ background =Screen . colors . DarkGreen } , 1878[ 6 ] ={ background =Screen . colors . DarkGreen , bold =true , foreground =Screen . colors . Blue1 } , 1879[ 7 ] ={ background =Screen . colors . DarkMagenta } , 1880[ 8 ] ={ 1881background =Screen . colors . DarkMagenta , 1882bold =true , 1883foreground =Screen . colors . Blue1 , 1884} , 1885[ 9 ] ={ foreground =Screen . colors . Brown } , 1886[ 10 ] ={ foreground =Screen . colors . Brown , background =Screen . colors . DarkBlue } , 1887[ 11 ] ={ background =Screen . colors . DarkBlue , bold =true , reverse =true } , 1888[ 12 ] ={ background =Screen . colors . DarkGreen , reverse =true } , 1889[ 13 ] ={ background =Screen . colors . Magenta4 , reverse =true } , 1890[ 14 ] ={ background =Screen . colors . DarkBlue , reverse =true } , 1891[ 15 ] ={ foreground =Screen . colors . Grey100 , background =Screen . colors . Red } , 1892[ 16 ] ={ foreground =Screen . colors . Blue1 } , 1893[ 17 ] ={ background =Screen . colors . LightRed } , 1894[ 18 ] ={ background =Screen . colors . Gray90 } , 1895[ 19 ] ={ foreground =Screen . colors . LightGrey , background =Screen . colors . DarkGray } , 1896[ 20 ] ={ background =Screen . colors . LightGrey , underline =true } , 1897[ 21 ] ={ bold =true } , 1898[ 22 ] ={ bold =true , foreground =Screen . colors . SeaGreen4 } , 1899[ 23 ] ={ background =Screen . colors . LightMagenta } , 1900[ 24 ] ={ background =Screen . colors . WebGray } , 1901[ 25 ] ={ bold =true , foreground =Screen . colors . Green1 } , 1902[ 26 ] ={ background =Screen . colors . Red } , 1903[ 27 ] ={ background =Screen . colors . DarkBlue , bold =true , foreground =Screen . colors . Green1 } , 1904[ 28 ] ={ bold =true , foreground =Screen . colors . Brown } , 1905[ 29 ] ={ foreground =Screen . colors . Blue1 , background =Screen . colors . Red , bold =true } , 1906[ 30 ] ={ background =tonumber ( '0xff8800' ) } , 1907[ 31 ] ={ background =tonumber ( '0xff8800' ), bold =true , foreground =Screen . colors . Blue } , 1908[ 32 ] ={ bold =true , reverse =true , background =Screen . colors . DarkGreen } , 1909} 1910command ( 'hi Background1 guibg=DarkBlue' ) 1911command ( 'hi Background2 guibg=DarkGreen' ) 1912end ) 1913 1914it ( 'works for background color' , function () 1915insert ( 'aa' ) 1916command ( 'split' ) 1917command ( 'set winhl=Normal:Background1' ) 1918screen : expect ( [[ 1919{1:a^a }| 1920{2:~ }|*2 1921{3:[No Name] [+] }| 1922aa | 1923{0:~ }| 1924{4:[No Name] [+] }| 1925| 1926]] ) 1927 1928command ( 'enew' ) 1929screen : expect ( [[ 1930{1:^ }| 1931{2:~ }|*2 1932{3:[No Name] }| 1933aa | 1934{0:~ }| 1935{4:[No Name] [+] }| 1936| 1937]] ) 1938end ) 1939 1940it ( 'works for background color in rightleft window #22640' , function () 1941-- Use a wide screen to also check that this doesn't overflow linebuf_attr. 1942screen : try_resize ( 80 , 6 ) 1943insert ( 'aa' ) 1944command ( 'setlocal rightleft' ) 1945command ( 'setlocal winhl=Normal:Background1' ) 1946screen : expect ( [[ 1947{1: ^aa}| 1948{2: ~}|*4 1949| 1950]] ) 1951command ( 'botright vsplit' ) 1952screen : expect ( [[ 1953{1: aa│ ^aa}| 1954{2: ~}{1:│}{2: ~}|*3 1955{4:[No Name] [+] }{3:[No Name] [+] }| 1956| 1957]] ) 1958end ) 1959 1960it ( 'handles undefined groups' , function () 1961command ( 'set winhl=Normal:Background1' ) 1962screen : expect ( [[ 1963{1:^ }| 1964{2:~ }|*6 1965| 1966]] ) 1967 1968command ( 'set winhl=xxx:yyy' ) 1969eq ( 'xxx:yyy' , eval ( '&winhl' )) 1970screen : expect { 1971grid =[[ 1972^ | 1973{0:~ }|*6 1974| 1975]] , 1976} 1977end ) 1978 1979it ( 'can be changed to define different groups' , function () 1980command ( 'set winhl=EndOfBuffer:Background1' ) 1981screen : expect { 1982grid =[[ 1983^ | 1984{1:~ }|*6 1985| 1986]] , 1987} 1988 1989command ( 'set winhl=Normal:ErrorMsg' ) 1990screen : expect { 1991grid =[[ 1992{15:^ }| 1993{29:~ }|*6 1994| 1995]] , 1996} 1997end ) 1998 1999it ( 'works local to the window' , function () 2000insert ( 'aa' ) 2001command ( 'split' ) 2002command ( 'setlocal winhl=Normal:Background1' ) 2003screen : expect ( [[ 2004{1:a^a }| 2005{2:~ }|*2 2006{3:[No Name] [+] }| 2007aa | 2008{0:~ }| 2009{4:[No Name] [+] }| 2010| 2011]] ) 2012 2013command ( 'enew' ) 2014screen : expect ( [[ 2015^ | 2016{0:~ }|*2 2017{3:[No Name] }| 2018aa | 2019{0:~ }| 2020{4:[No Name] [+] }| 2021| 2022]] ) 2023 2024command ( 'bnext' ) 2025screen : expect ( [[ 2026{1:^aa }| 2027{2:~ }|*2 2028{3:[No Name] [+] }| 2029aa | 2030{0:~ }| 2031{4:[No Name] [+] }| 2032| 2033]] ) 2034end ) 2035 2036it ( 'for inactive window background works' , function () 2037command ( 'set winhl=Normal:Background1,NormalNC:Background2' ) 2038-- tests global value is copied across split 2039command ( 'split' ) 2040screen : expect ( [[ 2041{1:^ }| 2042{2:~ }|*2 2043{3:[No Name] }| 2044{5: }| 2045{6:~ }| 2046{4:[No Name] }| 2047| 2048]] ) 2049 2050feed ( '<c-w><c-w>' ) 2051screen : expect ( [[ 2052{5: }| 2053{6:~ }|*2 2054{4:[No Name] }| 2055{1:^ }| 2056{2:~ }| 2057{3:[No Name] }| 2058| 2059]] ) 2060 2061feed ( '<c-w><c-w>' ) 2062screen : expect ( [[ 2063{1:^ }| 2064{2:~ }|*2 2065{3:[No Name] }| 2066{5: }| 2067{6:~ }| 2068{4:[No Name] }| 2069| 2070]] ) 2071end ) 2072 2073it ( 'works with NormalNC' , function () 2074command ( 'hi NormalNC guibg=DarkMagenta' ) 2075-- tests global value is copied across split 2076command ( 'split' ) 2077screen : expect ( [[ 2078^ | 2079{0:~ }|*2 2080{3:[No Name] }| 2081{7: }| 2082{8:~ }| 2083{4:[No Name] }| 2084| 2085]] ) 2086 2087command ( 'wincmd w' ) 2088screen : expect ( [[ 2089{7: }| 2090{8:~ }|*2 2091{4:[No Name] }| 2092^ | 2093{0:~ }| 2094{3:[No Name] }| 2095| 2096]] ) 2097 2098-- winbg=Normal:... overrides global NormalNC 2099command ( 'set winhl=Normal:Background1' ) 2100screen : expect ( [[ 2101{7: }| 2102{8:~ }|*2 2103{4:[No Name] }| 2104{1:^ }| 2105{2:~ }| 2106{3:[No Name] }| 2107| 2108]] ) 2109 2110command ( 'wincmd w' ) 2111screen : expect ( [[ 2112^ | 2113{0:~ }|*2 2114{3:[No Name] }| 2115{1: }| 2116{2:~ }| 2117{4:[No Name] }| 2118| 2119]] ) 2120 2121command ( 'wincmd w' ) 2122command ( 'set winhl=Normal:Background1,NormalNC:Background2' ) 2123screen : expect ( [[ 2124{7: }| 2125{8:~ }|*2 2126{4:[No Name] }| 2127{1:^ }| 2128{2:~ }| 2129{3:[No Name] }| 2130| 2131]] ) 2132 2133command ( 'wincmd w' ) 2134screen : expect ( [[ 2135^ | 2136{0:~ }|*2 2137{3:[No Name] }| 2138{5: }| 2139{6:~ }| 2140{4:[No Name] }| 2141| 2142]] ) 2143end ) 2144 2145it ( 'updates background to changed linked group' , function () 2146command ( 'split' ) 2147command ( 'setlocal winhl=Normal:FancyGroup' ) -- does not yet exist 2148screen : expect { 2149grid =[[ 2150^ | 2151{0:~ }|*2 2152{3:[No Name] }| 2153| 2154{0:~ }| 2155{4:[No Name] }| 2156| 2157]] , 2158} 2159 2160command ( 'hi FancyGroup guibg=#FF8800' ) -- nice orange 2161screen : expect { 2162grid =[[ 2163{30:^ }| 2164{31:~ }|*2 2165{3:[No Name] }| 2166| 2167{0:~ }| 2168{4:[No Name] }| 2169| 2170]] , 2171} 2172end ) 2173 2174it ( 'background applies also to non-text' , function () 2175command ( 'set sidescroll=0' ) 2176insert ( 'Lorem ipsum dolor sit amet ' ) 2177command ( 'set shiftwidth=2' ) 2178feed ( '>>' ) 2179command ( 'set number' ) 2180command ( 'set breakindent' ) 2181command ( 'set briopt=shift:5,min:0' ) 2182command ( 'set list' ) 2183command ( 'set showbreak=↪' ) 2184screen : expect ( [[ 2185{9: 1 } ^Lorem ipsum do| 2186{9: } {0:↪}lor sit | 2187{9: } {0:↪}amet{0:-} | 2188{0:~ }|*4 2189| 2190]] ) 2191 2192command ( 'set winhl=Normal:Background1' ) 2193screen : expect ( [[ 2194{10: 1 }{1: ^Lorem ipsum do}| 2195{10: }{1: }{2:↪}{1:lor sit }| 2196{10: }{1: }{2:↪}{1:amet}{2:-}{1: }| 2197{2:~ }|*4 2198| 2199]] ) 2200 2201command ( 'set nowrap' ) 2202command ( 'set listchars+=extends:❯,precedes:❮' ) 2203feed ( '3w' ) 2204screen : expect ( [[ 2205{10: 1 }{2:❮}{1: dolor ^sit ame}{2:❯}| 2206{2:~ }|*6 2207| 2208]] ) 2209end ) 2210 2211it ( "background doesn't override syntax background" , function () 2212command ( 'syntax on' ) 2213command ( 'syntax keyword Foobar foobar' ) 2214command ( 'syntax keyword Article the' ) 2215command ( 'hi Foobar guibg=#FF0000' ) 2216command ( 'hi Article guifg=#00FF00 gui=bold' ) 2217insert ( 'the foobar was foobar' ) 2218screen : expect ( [[ 2219{25:the} {26:foobar} was {26:fooba}| 2220{26:^r} | 2221{0:~ }|*5 2222| 2223]] ) 2224 2225-- winhl=Normal:Group with background doesn't override syntax background, 2226-- but does combine with syntax foreground. 2227command ( 'set winhl=Normal:Background1' ) 2228screen : expect ( [[ 2229{27:the}{1: }{26:foobar}{1: was }{26:fooba}| 2230{26:^r}{1: }| 2231{2:~ }|*5 2232| 2233]] ) 2234end ) 2235 2236it ( 'can override NonText, Conceal and EndOfBuffer' , function () 2237api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 'raa\000' } ) 2238command ( 'call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})' ) 2239command ( 'set cole=2 cocu=nvic' ) 2240command ( 'split' ) 2241command ( 'call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})' ) 2242command ( 'set winhl=SpecialKey:ErrorMsg,EndOfBuffer:Background1,' .. 'Conceal:Background2' ) 2243 2244screen : expect ( [[ 2245^r{5:#}a{15:^@} | 2246{1:~ }|*2 2247{3:[No Name] [+] }| 2248r{19:#}a{16:^@} | 2249{0:~ }| 2250{4:[No Name] [+] }| 2251| 2252]] ) 2253end ) 2254 2255it ( 'can override LineNr, CursorColumn and ColorColumn' , function () 2256insert ( 'very text\nmore text' ) 2257command ( 'set number' ) 2258command ( 'set colorcolumn=2' ) 2259command ( 'set cursorcolumn' ) 2260feed ( 'k' ) 2261 2262command ( 'split' ) 2263command ( 'set winhl=LineNr:Background1,CursorColumn:Background2,' .. 'ColorColumn:ErrorMsg' ) 2264screen : expect ( [[ 2265{1: 1 }v{15:e}ry tex^t | 2266{1: 2 }m{15:o}re tex{5:t} | 2267{0:~ }| 2268{3:[No Name] [+] }| 2269{9: 1 }v{17:e}ry text | 2270{9: 2 }m{17:o}re tex{18:t} | 2271{4:[No Name] [+] }| 2272| 2273]] ) 2274end ) 2275 2276it ( 'can override Tabline' , function () 2277command ( 'tabnew' ) 2278command ( 'set winhl=TabLine:Background1,TabLineSel:ErrorMsg' ) 2279 2280screen : expect ( [[ 2281{20: No Name] }{15: No Name]}{20:X}| 2282^ | 2283{0:~ }|*5 2284| 2285]] ) 2286command ( 'tabnext' ) 2287screen : expect ( [[ 2288{21: No Name] }{1: No Name]}{20:X}| 2289^ | 2290{0:~ }|*5 2291| 2292]] ) 2293end ) 2294 2295it ( 'can override popupmenu' , function () 2296insert ( 'word wording wordy' ) 2297command ( 'split' ) 2298command ( 2299'set winhl=Pmenu:Background1,PmenuSel:Background2,' .. 'PmenuSbar:ErrorMsg,PmenuThumb:Normal' 2300) 2301screen : expect ( [[ 2302word wording word^y | 2303{0:~ }|*2 2304{3:[No Name] [+] }| 2305word wording wordy | 2306{0:~ }| 2307{4:[No Name] [+] }| 2308| 2309]] ) 2310 2311feed ( 'oword<c-x><c-p>' ) 2312screen : expect ( [[ 2313word wording wordy | 2314wordy^ | 2315{1:word }{0: }| 2316{1:wording }{3: }| 2317{5:wordy }rdy | 2318wordy | 2319{4:[No Name] [+] }| 2320{21:-- }{22:match 1 of 3} | 2321]] ) 2322 2323feed ( '<esc>u<c-w><c-w>oword<c-x><c-p>' ) 2324screen : expect ( [[ 2325word wording wordy | 2326wordy | 2327{23:word }{0: }| 2328{23:wording }{4: }| 2329{24:wordy }rdy | 2330wordy^ | 2331{3:[No Name] [+] }| 2332{21:-- }{22:match 1 of 3} | 2333]] ) 2334end ) 2335 2336it ( 'can override CursorLine and CursorLineNr' , function () 2337-- CursorLine used to be parsed as CursorLineNr, because strncmp 2338command ( 'set cursorline number' ) 2339command ( 'split' ) 2340command ( 'set winhl=CursorLine:Background1' ) 2341screen : expect { 2342grid =[[ 2343{28: 1 }{1:^ }| 2344{0:~ }|*2 2345{3:[No Name] }| 2346{28: 1 }{18: }| 2347{0:~ }| 2348{4:[No Name] }| 2349| 2350]] , 2351} 2352 2353command ( 'set winhl=CursorLineNr:Background2,CursorLine:Background1' ) 2354screen : expect { 2355grid =[[ 2356{5: 1 }{1:^ }| 2357{0:~ }|*2 2358{3:[No Name] }| 2359{28: 1 }{18: }| 2360{0:~ }| 2361{4:[No Name] }| 2362| 2363]] , 2364} 2365 2366feed ( '<c-w>w' ) 2367screen : expect { 2368grid =[[ 2369{5: 1 }{1: }| 2370{0:~ }|*2 2371{4:[No Name] }| 2372{28: 1 }{18:^ }| 2373{0:~ }| 2374{3:[No Name] }| 2375| 2376]] , 2377} 2378end ) 2379 2380it ( 'can override StatusLine and StatusLineNC' , function () 2381command ( 'set winhighlight=StatusLine:Background1,StatusLineNC:Background2' ) 2382command ( 'split' ) 2383screen : expect ( [[ 2384^ | 2385{0:~ }|*2 2386{1:[No Name] }| 2387| 2388{0:~ }| 2389{5:[No Name] }| 2390| 2391]] ) 2392end ) 2393 2394it ( 'can override WinBar and WinBarNC #19345' , function () 2395command ( 'setlocal winbar=foobar' ) 2396command ( 'set winhighlight=WinBar:Background1,WinBarNC:Background2' ) 2397command ( 'split' ) 2398screen : expect ( [[ 2399{1:foobar }| 2400^ | 2401{0:~ }| 2402{3:[No Name] }| 2403{5:foobar }| 2404| 2405{4:[No Name] }| 2406| 2407]] ) 2408end ) 2409 2410it ( 'can override syntax groups' , function () 2411command ( 'syntax on' ) 2412command ( 'syntax keyword Foobar foobar' ) 2413command ( 'syntax keyword Article the' ) 2414command ( 'hi Foobar guibg=#FF0000' ) 2415command ( 'hi Article guifg=#00FF00 gui=bold' ) 2416insert ( 'the foobar was foobar' ) 2417screen : expect ( [[ 2418{25:the} {26:foobar} was {26:fooba}| 2419{26:^r} | 2420{0:~ }|*5 2421| 2422]] ) 2423 2424command ( 'split' ) 2425command ( 'set winhl=Foobar:Background1,Article:ErrorMsg' ) 2426screen : expect { 2427grid =[[ 2428{15:the} {1:foobar} was {1:fooba}| 2429{1:^r} | 2430{0:~ }| 2431{3:[No Name] [+] }| 2432{25:the} {26:foobar} was {26:fooba}| 2433{26:r} | 2434{4:[No Name] [+] }| 2435| 2436]] , 2437} 2438end ) 2439 2440it ( 'can be disabled in newly opened window #19823' , function () 2441command ( 'split | set winhl=Normal:ErrorMsg | set winhl=' ) 2442screen : expect { 2443grid =[[ 2444^ | 2445{0:~ }|*2 2446{3:[No Name] }| 2447| 2448{0:~ }| 2449{4:[No Name] }| 2450| 2451]] , 2452} 2453 2454n . assert_alive () 2455end ) 2456 2457it ( 'can redraw statusline on cursor movement' , function () 2458screen : try_resize ( 40 , 8 ) 2459exec [[ 2460set statusline=%f%=%#Background1#%l,%c%V\ %P 2461split 2462]] 2463insert [[ 2464some text 2465more text]] 2466screen : expect { 2467grid =[[ 2468some text | 2469more tex^t | 2470{0:~ }| 2471{3:[No Name] }{11:2,9 All}| 2472some text | 2473more text | 2474{4:[No Name] }{14:1,1 All}| 2475| 2476]] , 2477} 2478 2479command 'set winhl=Background1:Background2' 2480screen : expect { 2481grid =[[ 2482some text | 2483more tex^t | 2484{0:~ }| 2485{3:[No Name] }{32:2,9 All}| 2486some text | 2487more text | 2488{4:[No Name] }{14:1,1 All}| 2489| 2490]] , 2491} 2492 2493feed 'k' 2494screen : expect { 2495grid =[[ 2496some tex^t | 2497more text | 2498{0:~ }| 2499{3:[No Name] }{32:1,9 All}| 2500some text | 2501more text | 2502{4:[No Name] }{14:1,1 All}| 2503| 2504]] , 2505} 2506end ) 2507 2508it ( 'can link to empty highlight group' , function () 2509command 'hi NormalNC guibg=Red' -- czerwone time 2510command 'set winhl=NormalNC:Normal' 2511command 'split' 2512 2513screen : expect { 2514grid =[[ 2515^ | 2516{0:~ }|*2 2517{3:[No Name] }| 2518| 2519{0:~ }| 2520{4:[No Name] }| 2521| 2522]] , 2523} 2524end ) 2525end ) 2526 2527describe ( 'highlight namespaces' , function () 2528local screen 2529local ns1 , ns2 2530 2531before_each ( function () 2532clear () 2533screen =Screen . new ( 25 , 10 ) 2534screen : set_default_attr_ids { 2535[ 1 ] ={ foreground =Screen . colors . Blue , bold =true } , 2536[ 2 ] ={ background =Screen . colors . DarkGrey } , 2537[ 3 ] ={ 2538italic =true , 2539foreground =Screen . colors . DarkCyan , 2540background =Screen . colors . DarkOrange4 , 2541} , 2542[ 4 ] ={ background =Screen . colors . Magenta4 } , 2543[ 5 ] ={ background =Screen . colors . Magenta4 , foreground =Screen . colors . Crimson } , 2544[ 6 ] ={ bold =true , reverse =true } , 2545[ 7 ] ={ reverse =true } , 2546[ 8 ] ={ foreground =Screen . colors . Gray20 } , 2547[ 9 ] ={ foreground =Screen . colors . Blue } , 2548[ 10 ] ={ bold =true , foreground =Screen . colors . SeaGreen } , 2549} 2550 2551ns1 =api . nvim_create_namespace 'grungy' 2552ns2 =api . nvim_create_namespace 'ultrared' 2553 2554api . nvim_set_hl ( ns1 , 'Normal' , { bg ='DarkGrey' } ) 2555api . nvim_set_hl ( ns1 , 'NonText' , { bg ='DarkOrange4' , fg ='DarkCyan' , italic =true } ) 2556api . nvim_set_hl ( ns2 , 'Normal' , { bg ='DarkMagenta' } ) 2557api . nvim_set_hl ( ns2 , 'NonText' , { fg ='Crimson' } ) 2558end ) 2559 2560it ( 'can be used globally' , function () 2561screen : expect { 2562grid =[[ 2563^ | 2564{1:~ }|*8 2565| 2566]] , 2567} 2568 2569api . nvim_set_hl_ns ( ns1 ) 2570screen : expect { 2571grid =[[ 2572{2:^ }| 2573{3:~ }|*8 2574| 2575]] , 2576} 2577 2578api . nvim_set_hl_ns ( ns2 ) 2579screen : expect { 2580grid =[[ 2581{4:^ }| 2582{5:~ }|*8 2583| 2584]] , 2585} 2586 2587api . nvim_set_hl_ns ( 0 ) 2588screen : expect { 2589grid =[[ 2590^ | 2591{1:~ }|*8 2592| 2593]] , 2594} 2595end ) 2596 2597it ( 'can be used per window' , function () 2598local win1 =api . nvim_get_current_win () 2599command 'split' 2600local win2 =api . nvim_get_current_win () 2601command 'split' 2602 2603api . nvim_win_set_hl_ns ( win1 , ns1 ) 2604api . nvim_win_set_hl_ns ( win2 , ns2 ) 2605 2606screen : expect { 2607grid =[[ 2608^ | 2609{1:~ }| 2610{6:[No Name] }| 2611{4: }| 2612{5:~ }| 2613{7:[No Name] }| 2614{2: }| 2615{3:~ }| 2616{7:[No Name] }| 2617| 2618]] , 2619} 2620end ) 2621 2622it ( 'redraws correctly when ns=0' , function () 2623screen : expect { 2624grid =[[ 2625^ | 2626{1:~ }|*8 2627| 2628]] , 2629} 2630 2631api . nvim_set_hl ( 0 , 'EndOfBuffer' , { fg ='#333333' } ) 2632screen : expect { 2633grid =[[ 2634^ | 2635{8:~ }|*8 2636| 2637]] , 2638} 2639end ) 2640 2641it ( 'winhl does not accept invalid value #24586' , function () 2642command ( 'set winhl=Normal:Visual' ) 2643for _ , cmd in ipairs ( { 2644[[set winhl='Normal:Wrong']] , 2645[[set winhl=Normal:Wrong']] , 2646[[set winhl='Normal:Wrong]] , 2647} ) do 2648local res =exec_lua ( 2649[[ 2650local _, msg = pcall(vim.api.nvim_command, ...) 2651return { msg, vim.wo.winhl } 2652]] , 2653cmd 2654) 2655eq ( { 2656'Vim(set):E5248: Invalid character in group name' , 2657'Normal:Visual' , 2658} , res ) 2659end 2660end ) 2661 2662it ( 'Normal in set_hl #25474' , function () 2663command ( 'highlight Ignore guifg=bg ctermfg=White' ) 2664api . nvim_set_hl ( 0 , 'Normal' , { bg ='#333333' } ) 2665command ( 'highlight Ignore' ) 2666screen : expect { 2667grid =[[ 2668| 2669{1:~ }|*2 2670{6: }| 2671| 2672Ignore {8:xxx} {9:ctermf}| 2673{9:g=}15 {9:guifg=}| 2674bg | 2675{10:Press ENTER or type comma}| 2676{10:nd to continue}^ | 2677]] , 2678} 2679end ) 2680end ) 2681 2682describe ( 'synIDattr()' , function () 2683before_each ( function () 2684clear () 2685command ( 'highlight Normal ctermfg=252 guifg=#ff0000 guibg=Black' ) 2686-- Salmon #fa8072 Maroon #800000 2687command ( 2688'highlight Keyword ctermfg=79 guifg=Salmon guisp=Maroon cterm=strikethrough gui=strikethrough' 2689) 2690end ) 2691 2692it ( 'returns cterm-color if RGB-capable UI is _not_ attached' , function () 2693eq ( '252' , eval ( 'synIDattr(hlID("Normal"), "fg")' )) 2694eq ( '252' , eval ( 'synIDattr(hlID("Normal"), "fg#")' )) 2695eq ( '' , eval ( 'synIDattr(hlID("Normal"), "bg")' )) 2696eq ( '' , eval ( 'synIDattr(hlID("Normal"), "bg#")' )) 2697eq ( '79' , eval ( 'synIDattr(hlID("Keyword"), "fg")' )) 2698eq ( '79' , eval ( 'synIDattr(hlID("Keyword"), "fg#")' )) 2699eq ( '' , eval ( 'synIDattr(hlID("Keyword"), "sp")' )) 2700eq ( '' , eval ( 'synIDattr(hlID("Keyword"), "sp#")' )) 2701end ) 2702 2703it ( 'returns gui-color if "gui" arg is passed' , function () 2704eq ( 'Black' , eval ( 'synIDattr(hlID("Normal"), "bg", "gui")' )) 2705eq ( 'Maroon' , eval ( 'synIDattr(hlID("Keyword"), "sp", "gui")' )) 2706end ) 2707 2708it ( 'returns gui-color if RGB-capable UI is attached' , function () 2709local _ =Screen . new ( 50 , 7 , { rgb =true } ) 2710eq ( '#ff0000' , eval ( 'synIDattr(hlID("Normal"), "fg")' )) 2711eq ( 'Black' , eval ( 'synIDattr(hlID("Normal"), "bg")' )) 2712eq ( 'Salmon' , eval ( 'synIDattr(hlID("Keyword"), "fg")' )) 2713eq ( 'Maroon' , eval ( 'synIDattr(hlID("Keyword"), "sp")' )) 2714end ) 2715 2716it ( 'returns #RRGGBB value for fg#/bg#/sp#' , function () 2717local _ =Screen . new ( 50 , 7 , { rgb =true } ) 2718eq ( '#ff0000' , eval ( 'synIDattr(hlID("Normal"), "fg#")' )) 2719eq ( '#000000' , eval ( 'synIDattr(hlID("Normal"), "bg#")' )) 2720eq ( '#fa8072' , eval ( 'synIDattr(hlID("Keyword"), "fg#")' )) 2721eq ( '#800000' , eval ( 'synIDattr(hlID("Keyword"), "sp#")' )) 2722end ) 2723 2724it ( 'returns color number if non-RGB GUI' , function () 2725local _ =Screen . new ( 50 , 7 , { rgb =false } ) 2726eq ( '252' , eval ( 'synIDattr(hlID("Normal"), "fg")' )) 2727eq ( '79' , eval ( 'synIDattr(hlID("Keyword"), "fg")' )) 2728end ) 2729 2730it ( 'returns "1" if group has given highlight attribute' , function () 2731local hl_attrs ={ 2732'underline' , 2733'undercurl' , 2734'underdouble' , 2735'underdotted' , 2736'underdashed' , 2737'strikethrough' , 2738} 2739for _ , hl_attr in ipairs ( hl_attrs ) do 2740local context ='using ' .. hl_attr .. ' attr' 2741command ( 'highlight Keyword cterm=' .. hl_attr .. ' gui=' .. hl_attr ) 2742eq ( '' , eval ( 'synIDattr(hlID("Normal"), "' .. hl_attr .. '")' ), context ) 2743eq ( '1' , eval ( 'synIDattr(hlID("Keyword"), "' .. hl_attr .. '")' ), context ) 2744eq ( '1' , eval ( 'synIDattr(hlID("Keyword"), "' .. hl_attr .. '", "gui")' ), context ) 2745end 2746end ) 2747end ) 2748 2749describe ( 'fg/bg special colors' , function () 2750before_each ( function () 2751clear () 2752command ( 'highlight Normal ctermfg=145 ctermbg=16 guifg=#ff0000 guibg=Black' ) 2753command ( 'highlight Visual ctermfg=bg ctermbg=fg guifg=bg guibg=fg guisp=bg' ) 2754end ) 2755 2756it ( 'resolve to "Normal" values' , function () 2757eq ( eval ( 'synIDattr(hlID("Normal"), "bg")' ), eval ( 'synIDattr(hlID("Visual"), "fg")' )) 2758eq ( eval ( 'synIDattr(hlID("Normal"), "bg#")' ), eval ( 'synIDattr(hlID("Visual"), "fg#")' )) 2759eq ( eval ( 'synIDattr(hlID("Normal"), "fg")' ), eval ( 'synIDattr(hlID("Visual"), "bg")' )) 2760eq ( eval ( 'synIDattr(hlID("Normal"), "fg#")' ), eval ( 'synIDattr(hlID("Visual"), "bg#")' )) 2761eq ( 'bg' , eval ( 'synIDattr(hlID("Visual"), "fg", "gui")' )) 2762eq ( 'bg' , eval ( 'synIDattr(hlID("Visual"), "fg#", "gui")' )) 2763eq ( 'fg' , eval ( 'synIDattr(hlID("Visual"), "bg", "gui")' )) 2764eq ( 'fg' , eval ( 'synIDattr(hlID("Visual"), "bg#", "gui")' )) 2765eq ( 'bg' , eval ( 'synIDattr(hlID("Visual"), "sp", "gui")' )) 2766eq ( 'bg' , eval ( 'synIDattr(hlID("Visual"), "sp#", "gui")' )) 2767end ) 2768 2769it ( 'resolve to "Normal" values in RGB-capable UI' , function () 2770local _ =Screen . new ( 50 , 7 , { rgb =true } ) 2771eq ( 'bg' , eval ( 'synIDattr(hlID("Visual"), "fg")' )) 2772eq ( eval ( 'synIDattr(hlID("Normal"), "bg#")' ), eval ( 'synIDattr(hlID("Visual"), "fg#")' )) 2773eq ( 'fg' , eval ( 'synIDattr(hlID("Visual"), "bg")' )) 2774eq ( eval ( 'synIDattr(hlID("Normal"), "fg#")' ), eval ( 'synIDattr(hlID("Visual"), "bg#")' )) 2775eq ( 'bg' , eval ( 'synIDattr(hlID("Visual"), "sp")' )) 2776eq ( eval ( 'synIDattr(hlID("Normal"), "bg#")' ), eval ( 'synIDattr(hlID("Visual"), "sp#")' )) 2777end ) 2778 2779it ( 'resolve after the "Normal" group is modified' , function () 2780local _ =Screen . new ( 50 , 7 , { rgb =true } ) 2781local new_guibg ='#282c34' 2782local new_guifg ='#abb2bf' 2783command ( 'highlight Normal guifg=' .. new_guifg .. ' guibg=' .. new_guibg ) 2784eq ( new_guibg , eval ( 'synIDattr(hlID("Visual"), "fg#")' )) 2785eq ( new_guifg , eval ( 'synIDattr(hlID("Visual"), "bg#")' )) 2786eq ( new_guibg , eval ( 'synIDattr(hlID("Visual"), "sp#")' )) 2787end ) 2788 2789it ( 'changed highlight is reflected in messages before redraw #17832' , function () 2790local screen =Screen . new ( 50 , 7 , { rgb =true } ) 2791command ( 'set termguicolors' ) 2792-- :echomsg in the same request, before the next redraw. 2793command ( 'call nvim_set_hl(0, "MsgArea", {"fg": "Red"}) | echomsg "foo"' ) 2794screen : expect ( { 2795grid =[[ 2796^ | 2797{1:~ }|*5 2798{19:foo }| 2799]] , 2800} ) 2801end ) 2802end )