robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
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 eq =t . eq 7local feed =n . feed 8local clear =n . clear 9local api =n . api 10local fn =n . fn 11local source =n . source 12local exec_capture =n . exec_capture 13local dedent =t . dedent 14local command =n . command 15 16local screen 17 18-- Bug in input() handling: :redraw! will erase the whole prompt up until 19-- user types something. It exists in Vim as well, so using `h<BS>` as 20-- a workaround. 21local function redraw_input () 22feed ( '{REDRAW}h<BS>' ) 23end 24 25before_each ( function () 26clear () 27screen =Screen . new ( 40 , 8 ) 28source ( [[ 29highlight RBP1 guibg=Red 30highlight RBP2 guibg=Yellow 31highlight RBP3 guibg=Green 32highlight RBP4 guibg=Blue 33let g:NUM_LVLS = 4 34function Redraw() 35mode 36return "\<Ignore>" 37endfunction 38let g:id = '' 39cnoremap <expr> {REDRAW} Redraw() 40function DoPrompt(do_return) abort 41let id = g:id 42let Cb = g:Nvim_color_input{g:id} 43let out = input({'prompt': ':', 'highlight': Cb}) 44let g:out{id} = out 45return (a:do_return ? out : "\<Ignore>") 46endfunction 47nnoremap <expr> {PROMPT} DoPrompt(0) 48cnoremap <expr> {PROMPT} DoPrompt(1) 49function RainBowParens(cmdline) 50let ret = [] 51let i = 0 52let lvl = 0 53while i < len(a:cmdline) 54if a:cmdline[i] is# '(' 55call add(ret, [i, i + 1, 'RBP' . ((lvl % g:NUM_LVLS) + 1)]) 56let lvl += 1 57elseif a:cmdline[i] is# ')' 58let lvl -= 1 59call add(ret, [i, i + 1, 'RBP' . ((lvl % g:NUM_LVLS) + 1)]) 60endif 61let i += 1 62endwhile 63return ret 64endfunction 65function SplitMultibyteStart(cmdline) 66let ret = [] 67let i = 0 68while i < len(a:cmdline) 69let char = nr2char(char2nr(a:cmdline[i:])) 70if a:cmdline[i:i + len(char) - 1] is# char 71if len(char) > 1 72call add(ret, [i + 1, i + len(char), 'RBP2']) 73endif 74let i += len(char) 75else 76let i += 1 77endif 78endwhile 79return ret 80endfunction 81function SplitMultibyteEnd(cmdline) 82let ret = [] 83let i = 0 84while i < len(a:cmdline) 85let char = nr2char(char2nr(a:cmdline[i:])) 86if a:cmdline[i:i + len(char) - 1] is# char 87if len(char) > 1 88call add(ret, [i, i + 1, 'RBP1']) 89endif 90let i += len(char) 91else 92let i += 1 93endif 94endwhile 95return ret 96endfunction 97function Echoing(cmdline) 98echo 'HERE' 99return v:_null_list 100endfunction 101function Echoning(cmdline) 102echon 'HERE' 103return v:_null_list 104endfunction 105function Echomsging(cmdline) 106echomsg 'HERE' 107return v:_null_list 108endfunction 109function Echoerring(cmdline) 110echoerr 'HERE' 111return v:_null_list 112endfunction 113function Redrawing(cmdline) 114redraw! 115return v:_null_list 116endfunction 117function Throwing(cmdline) 118throw "ABC" 119return v:_null_list 120endfunction 121function Halting(cmdline) 122while 1 123endwhile 124endfunction 125function ReturningGlobal(cmdline) 126return g:callback_return 127endfunction 128function ReturningGlobal2(cmdline) 129return g:callback_return[:len(a:cmdline)-1] 130endfunction 131function ReturningGlobalN(n, cmdline) 132return g:callback_return{a:n} 133endfunction 134let g:recording_calls = [] 135function Recording(cmdline) 136call add(g:recording_calls, a:cmdline) 137return [] 138endfunction 139]] ) 140screen : set_default_attr_ids ( { 141RBP1 ={ background =Screen . colors . Red } , 142RBP2 ={ background =Screen . colors . Yellow } , 143RBP3 ={ background =Screen . colors . Green } , 144RBP4 ={ background =Screen . colors . Blue } , 145EOB ={ bold =true , foreground =Screen . colors . Blue1 } , 146ERR ={ foreground =Screen . colors . Grey100 , background =Screen . colors . Red } , 147SK ={ foreground =Screen . colors . Blue } , 148PE ={ bold =true , foreground =Screen . colors . SeaGreen4 } , 149NUM ={ foreground =Screen . colors . Blue2 } , 150NPAR ={ foreground =Screen . colors . Yellow } , 151SQ ={ foreground =Screen . colors . Blue3 } , 152SB ={ foreground =Screen . colors . Blue4 } , 153E ={ foreground =Screen . colors . Red , background =Screen . colors . Blue } , 154M ={ bold =true } , 155MSEP ={ bold =true , reverse =true } , 156} ) 157end ) 158 159local function set_color_cb ( funcname , callback_return , id ) 160api . nvim_set_var ( 'id' , id or '' ) 161if id and id ~= '' and fn . exists ( '*' .. funcname .. 'N' ) == 1 then 162command (( 'let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}' ): format ( id , funcname , id )) 163if callback_return then 164api . nvim_set_var ( 'callback_return' .. id , callback_return ) 165end 166else 167api . nvim_set_var ( 'Nvim_color_input' , funcname ) 168if callback_return then 169api . nvim_set_var ( 'callback_return' , callback_return ) 170end 171end 172end 173local function start_prompt ( text ) 174feed ( '{PROMPT}' .. ( text or '' )) 175end 176 177describe ( 'Command-line coloring' , function () 178it ( 'works' , function () 179set_color_cb ( 'RainBowParens' ) 180api . nvim_set_option_value ( 'more' , false , {} ) 181start_prompt () 182screen : expect ( [[ 183| 184{EOB:~ }|*6 185:^ | 186]] ) 187feed ( 'e' ) 188screen : expect ( [[ 189| 190{EOB:~ }|*6 191:e^ | 192]] ) 193feed ( 'cho ' ) 194screen : expect ( [[ 195| 196{EOB:~ }|*6 197:echo ^ | 198]] ) 199feed ( '(' ) 200screen : expect ( [[ 201| 202{EOB:~ }|*6 203:echo {RBP1:(}^ | 204]] ) 205feed ( '(' ) 206screen : expect ( [[ 207| 208{EOB:~ }|*6 209:echo {RBP1:(}{RBP2:(}^ | 210]] ) 211feed ( '42' ) 212screen : expect ( [[ 213| 214{EOB:~ }|*6 215:echo {RBP1:(}{RBP2:(}42^ | 216]] ) 217feed ( '))' ) 218screen : expect ( [[ 219| 220{EOB:~ }|*6 221:echo {RBP1:(}{RBP2:(}42{RBP2:)}{RBP1:)}^ | 222]] ) 223feed ( '<BS>' ) 224screen : expect ( [[ 225| 226{EOB:~ }|*6 227:echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | 228]] ) 229redraw_input () 230screen : expect { 231grid =[[ 232| 233{EOB:~ }|*6 234:echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | 235]] , 236reset =true , 237} 238end ) 239for _ , func_part in ipairs ( { '' , 'n' , 'msg' } ) do 240it ( 'disables :echo' .. func_part .. ' messages' , function () 241set_color_cb ( 'Echo' .. func_part .. 'ing' ) 242start_prompt ( 'echo' ) 243screen : expect ( [[ 244| 245{EOB:~ }|*6 246:echo^ | 247]] ) 248end ) 249end 250it ( 'does the right thing when hl start appears to split multibyte char' , function () 251set_color_cb ( 'SplitMultibyteStart' ) 252start_prompt ( 'echo "«' ) 253screen : expect { 254grid =[[ 255| 256{EOB:~ }|*2 257{MSEP: }| 258:echo " | 259{ERR:E5405: Chunk 0 start 7 splits multibyte }| 260{ERR:character} | 261:echo "«^ | 262]] , 263} 264feed ( '»' ) 265screen : expect ( [[ 266| 267{EOB:~ }|*2 268{MSEP: }| 269:echo " | 270{ERR:E5405: Chunk 0 start 7 splits multibyte }| 271{ERR:character} | 272:echo "«»^ | 273]] ) 274end ) 275it ( 'does the right thing when hl end appears to split multibyte char' , function () 276set_color_cb ( 'SplitMultibyteEnd' ) 277start_prompt ( 'echo "«' ) 278screen : expect ( [[ 279| 280{EOB:~ }|*2 281{MSEP: }| 282:echo " | 283{ERR:E5406: Chunk 0 end 7 splits multibyte ch}| 284{ERR:aracter} | 285:echo "«^ | 286]] ) 287end ) 288it ( 'does the right thing when erroring' , function () 289set_color_cb ( 'Echoerring' ) 290start_prompt ( 'e' ) 291screen : expect ( [[ 292| 293{EOB:~ }| 294{MSEP: }| 295: | 296{ERR:E5407: Callback has thrown an exception:}| 297{ERR: function DoPrompt[3]..Echoerring, line }| 298{ERR:1: Vim(echoerr):HERE} | 299:e^ | 300]] ) 301end ) 302it ( 'silences :echo' , function () 303set_color_cb ( 'Echoing' ) 304start_prompt ( 'e' ) 305screen : expect ( [[ 306| 307{EOB:~ }|*6 308:e^ | 309]] ) 310eq ( '' , exec_capture ( 'messages' )) 311end ) 312it ( 'silences :echon' , function () 313set_color_cb ( 'Echoning' ) 314start_prompt ( 'e' ) 315screen : expect ( [[ 316| 317{EOB:~ }|*6 318:e^ | 319]] ) 320eq ( '' , exec_capture ( 'messages' )) 321end ) 322it ( 'silences :echomsg' , function () 323set_color_cb ( 'Echomsging' ) 324start_prompt ( 'e' ) 325screen : expect ( [[ 326| 327{EOB:~ }|*6 328:e^ | 329]] ) 330eq ( '' , exec_capture ( 'messages' )) 331end ) 332it ( 'does the right thing when throwing' , function () 333set_color_cb ( 'Throwing' ) 334start_prompt ( 'e' ) 335screen : expect ( [[ 336| 337{EOB:~ }| 338{MSEP: }| 339: | 340{ERR:E5407: Callback has thrown an exception:}| 341{ERR: function DoPrompt[3]..Throwing, line 1:}| 342{ERR: ABC} | 343:e^ | 344]] ) 345end ) 346it ( 'stops executing callback after a number of errors' , function () 347set_color_cb ( 'SplitMultibyteStart' ) 348start_prompt ( 'let x = "«»«»«»«»«»"' ) 349screen : expect ( [[ 350| 351{EOB:~ }|*2 352{MSEP: }| 353:let x = " | 354{ERR:E5405: Chunk 0 start 10 splits multibyte}| 355{ERR: character} | 356:let x = "«»«»«»«»«»"^ | 357]] ) 358feed ( '\n' ) 359screen : expect ( [[ 360^ | 361{EOB:~ }|*6 362| 363]] ) 364feed ( '\n' ) 365eq ( 'let x = "«»«»«»«»«»"' , api . nvim_get_var ( 'out' )) 366local msg ='\nE5405: Chunk 0 start 10 splits multibyte character' 367eq ( msg : rep ( 1 ), fn . execute ( 'messages' )) 368end ) 369it ( 'allows interrupting callback with <C-c>' , function () 370set_color_cb ( 'Halting' ) 371start_prompt ( 'echo 42' ) 372screen : expect ( [[ 373^ | 374{EOB:~ }|*6 375| 376]] ) 377screen : sleep ( 500 ) 378feed ( '<C-c>' ) 379screen : expect ( [[ 380| 381{EOB:~ }|*2 382{MSEP: }| 383: | 384{ERR:E5407: Callback has thrown an exception:}| 385{ERR: Keyboard interrupt} | 386:echo 42^ | 387]] ) 388redraw_input () 389screen : expect ( [[ 390| 391{EOB:~ }|*6 392:echo 42^ | 393]] ) 394feed ( '\n' ) 395screen : expect ( [[ 396^ | 397{EOB:~ }|*6 398:echo 42 | 399]] ) 400feed ( '\n' ) 401eq ( 'echo 42' , api . nvim_get_var ( 'out' )) 402feed ( '<C-c>' ) 403screen : expect ( [[ 404^ | 405{EOB:~ }|*6 406Type :qa and pre...nter> to exit Nvim | 407]] ) 408end ) 409it ( 'works fine with NUL, NL, CR' , function () 410set_color_cb ( 'RainBowParens' ) 411start_prompt ( 'echo ("<C-v><CR><C-v><Nul><C-v><NL>")' ) 412screen : expect ( [[ 413| 414{EOB:~ }|*6 415:echo {RBP1:(}"{SK:^M^@^@}"{RBP1:)}^ | 416]] ) 417end ) 418it ( 'errors out when callback returns something wrong' , function () 419command ( 'cnoremap + ++' ) 420set_color_cb ( 'ReturningGlobal' , '' ) 421start_prompt ( '#' ) 422screen : expect ( [[ 423| 424{EOB:~ }|*3 425{MSEP: }| 426: | 427{ERR:E5400: Callback should return list} | 428:#^ | 429]] ) 430 431feed ( '<CR><CR><CR>' ) 432set_color_cb ( 'ReturningGlobal' , { { 0 , 1 , 'Normal' } , 42 } ) 433start_prompt ( '#' ) 434screen : expect ( [[ 435| 436{EOB:~ }|*3 437{MSEP: }| 438: | 439{ERR:E5401: List item 1 is not a List} | 440:#^ | 441]] ) 442 443feed ( '<CR><CR><CR>' ) 444set_color_cb ( 'ReturningGlobal2' , { { 0 , 1 , 'Normal' } , { 1 } } ) 445start_prompt ( '+' ) 446screen : expect ( [[ 447| 448{EOB:~ }|*2 449{MSEP: }| 450:+ | 451{ERR:E5402: List item 1 has incorrect length:}| 452{ERR: 1 /= 3} | 453:++^ | 454]] ) 455 456feed ( '<CR><CR><CR>' ) 457set_color_cb ( 'ReturningGlobal2' , { { 0 , 1 , 'Normal' } , { 2 , 3 , 'Normal' } } ) 458start_prompt ( '+' ) 459screen : expect ( [[ 460| 461{EOB:~ }|*2 462{MSEP: }| 463:+ | 464{ERR:E5403: Chunk 1 start 2 not in range [1, }| 465{ERR:2)} | 466:++^ | 467]] ) 468 469feed ( '<CR><CR><CR>' ) 470set_color_cb ( 'ReturningGlobal2' , { { 0 , 1 , 'Normal' } , { 1 , 3 , 'Normal' } } ) 471start_prompt ( '+' ) 472screen : expect ( [[ 473| 474{EOB:~ }|*3 475{MSEP: }| 476:+ | 477{ERR:E5404: Chunk 1 end 3 not in range (1, 2]}| 478:++^ | 479]] ) 480end ) 481it ( 'does not error out when called from a errored out cycle' , function () 482set_color_cb ( 'ReturningGlobal' , { { 0 , 1 , 'Normal' } } ) 483feed ( dedent ( [[ 484:set regexpengine=2 485:for pat in [' \ze*', ' \zs*'] 486: try 487: let l = matchlist('x x', pat) 488: $put =input({'prompt':'>','highlight':'ReturningGlobal'}) 489: 490: $put ='E888 NOT detected for ' . pat 491: catch 492: $put =input({'prompt':'>','highlight':'ReturningGlobal'}) 493: 494: $put ='E888 detected for ' . pat 495: endtry 496:endfor 497: 498: 499: 500: 501: 502: 503]] )) 504eq ( 505{ '' , ':' , 'E888 detected for \\ze*' , ':' , 'E888 detected for \\zs*' } , 506api . nvim_buf_get_lines ( 0 , 0 , - 1 , false ) 507) 508eq ( '' , fn . execute ( 'messages' )) 509end ) 510it ( 'allows nesting input()s' , function () 511set_color_cb ( 'ReturningGlobal' , { { 0 , 1 , 'RBP1' } } , '' ) 512start_prompt ( '1' ) 513screen : expect ( [[ 514| 515{EOB:~ }|*6 516:{RBP1:1}^ | 517]] ) 518 519set_color_cb ( 'ReturningGlobal' , { { 0 , 1 , 'RBP2' } } , '1' ) 520start_prompt ( '2' ) 521screen : expect ( [[ 522| 523{EOB:~ }|*6 524:{RBP2:2}^ | 525]] ) 526 527set_color_cb ( 'ReturningGlobal' , { { 0 , 1 , 'RBP3' } } , '2' ) 528start_prompt ( '3' ) 529screen : expect ( [[ 530| 531{EOB:~ }|*6 532:{RBP3:3}^ | 533]] ) 534 535set_color_cb ( 'ReturningGlobal' , { { 0 , 1 , 'RBP4' } } , '3' ) 536start_prompt ( '4' ) 537screen : expect ( [[ 538| 539{EOB:~ }|*6 540:{RBP4:4}^ | 541]] ) 542 543feed ( '<CR>' ) 544screen : expect ( [[ 545| 546{EOB:~ }|*6 547:{RBP3:3}4^ | 548]] ) 549feed ( '<CR>' ) 550screen : expect ( [[ 551| 552{EOB:~ }|*6 553:{RBP2:2}34^ | 554]] ) 555feed ( '<CR>' ) 556screen : expect ( [[ 557| 558{EOB:~ }|*6 559:{RBP1:1}234^ | 560]] ) 561feed ( '<CR><CR><C-l>' ) 562screen : expect ( [[ 563^ | 564{EOB:~ }|*6 565| 566]] ) 567eq ( '1234' , api . nvim_get_var ( 'out' )) 568eq ( '234' , api . nvim_get_var ( 'out1' )) 569eq ( '34' , api . nvim_get_var ( 'out2' )) 570eq ( '4' , api . nvim_get_var ( 'out3' )) 571eq ( 0 , fn . exists ( 'g:out4' )) 572end ) 573it ( 'runs callback with the same data only once' , function () 574local function new_recording_calls ( ... ) 575eq ( { ... } , api . nvim_get_var ( 'recording_calls' )) 576api . nvim_set_var ( 'recording_calls' , {} ) 577end 578set_color_cb ( 'Recording' ) 579start_prompt ( '' ) 580-- Regression test. Disambiguation: 581-- 582-- new_recording_calls(expected_result) -- (actual_before_fix) 583-- 584feed ( 'a' ) 585new_recording_calls ( 'a' ) -- ('a', 'a') 586feed ( 'b' ) 587new_recording_calls ( 'ab' ) -- ('a', 'ab', 'ab') 588feed ( 'c' ) 589new_recording_calls ( 'abc' ) -- ('ab', 'abc', 'abc') 590feed ( '<BS>' ) 591new_recording_calls ( 'ab' ) -- ('abc', 'ab', 'ab') 592feed ( '<BS>' ) 593new_recording_calls ( 'a' ) -- ('ab', 'a', 'a') 594feed ( '<BS>' ) 595new_recording_calls () -- ('a') 596feed ( '<CR><CR>' ) 597eq ( '' , api . nvim_get_var ( 'out' )) 598end ) 599it ( 'does not crash when callback has caught not-a-editor-command exception' , function () 600source ( [[ 601function CaughtExc(cmdline) abort 602try 603gibberish 604catch 605" Do nothing 606endtry 607return [] 608endfunction 609]] ) 610set_color_cb ( 'CaughtExc' ) 611start_prompt ( '1' ) 612eq ( 1 , api . nvim_eval ( '1' )) 613end ) 614end ) 615describe ( 'Ex commands coloring' , function () 616it ( 'works' , function () 617api . nvim_set_var ( 'Nvim_color_cmdline' , 'RainBowParens' ) 618feed ( ':echo (((1)))' ) 619screen : expect ( [[ 620| 621{EOB:~ }|*6 622:echo {RBP1:(}{RBP2:(}{RBP3:(}1{RBP3:)}{RBP2:)}{RBP1:)}^ | 623]] ) 624end ) 625it ( 'still executes command-line even if errored out' , function () 626api . nvim_set_var ( 'Nvim_color_cmdline' , 'SplitMultibyteStart' ) 627feed ( ':let x = "«"\n' ) 628eq ( '«' , api . nvim_get_var ( 'x' )) 629local msg ='E5405: Chunk 0 start 10 splits multibyte character' 630eq ( '\n' .. msg , fn . execute ( 'messages' )) 631end ) 632it ( 'does not error out when called from a errored out cycle' , function () 633-- Apparently when there is a cycle in which one of the commands errors out 634-- this error may be caught by color_cmdline before it is presented to the 635-- user. 636feed ( dedent ( [[ 637:set regexpengine=2 638:for pat in [' \ze*', ' \zs*'] 639: try 640: let l = matchlist('x x', pat) 641: $put ='E888 NOT detected for ' . pat 642: catch 643: $put ='E888 detected for ' . pat 644: endtry 645:endfor 646]] )) 647eq ( 648{ '' , 'E888 detected for \\ze*' , 'E888 detected for \\zs*' } , 649api . nvim_buf_get_lines ( 0 , 0 , - 1 , false ) 650) 651eq ( '' , fn . execute ( 'messages' )) 652end ) 653it ( 'does not crash when using `n` in debug mode' , function () 654feed ( ':debug execute "echo 1"\n' ) 655screen : expect ( [[ 656| 657{EOB:~ }|*2 658{MSEP: }| 659Entering Debug mode. Type "cont" to con| 660tinue. | 661cmd: execute "echo 1" | 662>^ | 663]] ) 664feed ( 'n\n' ) 665screen : expect ( [[ 666| 667{MSEP: }| 668Entering Debug mode. Type "cont" to con| 669tinue. | 670cmd: execute "echo 1" | 671>n | 6721 | 673{PE:Press ENTER or type command to continue}^ | 674]] ) 675feed ( '\n' ) 676screen : expect ( [[ 677^ | 678{EOB:~ }|*6 679| 680]] ) 681end ) 682it ( 'mapping error does not cancel prompt' , function () 683command ( "cnoremap <expr> x execute('throw 42')[-1]" ) 684feed ( ':#x' ) 685screen : expect ( [[ 686| 687{EOB:~ }|*2 688{MSEP: }| 689:# | 690{ERR:Error in :} | 691{ERR:E605: Exception not caught: 42} | 692:#^ | 693]] ) 694feed ( '<CR>' ) 695screen : expect ( [[ 696| 697{EOB:~ }| 698{MSEP: }| 699:# | 700{ERR:Error in :} | 701{ERR:E605: Exception not caught: 42} | 702{ERR:E749: Empty buffer} | 703{PE:Press ENTER or type command to continue}^ | 704]] ) 705feed ( '<CR>' ) 706eq ( 'Error in :\nE605: Exception not caught: 42\nE749: Empty buffer' , exec_capture ( 'messages' )) 707end ) 708it ( 'errors out when failing to get callback' , function () 709api . nvim_set_var ( 'Nvim_color_cmdline' , 42 ) 710feed ( ':#' ) 711screen : expect ( [[ 712| 713{EOB:~ }| 714{MSEP: }| 715: | 716{ERR:E5408: Unable to get g:Nvim_color_cmdlin}| 717{ERR:e callback: Vim:E6000: Argument is not a}| 718{ERR: function or function name} | 719:#^ | 720]] ) 721end ) 722end ) 723describe ( 'Expressions coloring support' , function () 724it ( 'works' , function () 725command ( 'hi clear NvimNumber' ) 726command ( 'hi clear NvimNestingParenthesis' ) 727command ( 'hi NvimNumber guifg=Blue2' ) 728command ( 'hi NvimNestingParenthesis guifg=Yellow' ) 729feed ( ':echo <C-r>=(((1)))' ) 730screen : expect ( [[ 731| 732{EOB:~ }|*6 733={NPAR:(((}{NUM:1}{NPAR:)))}^ | 734]] ) 735end ) 736it ( 'does not use Nvim_color_expr' , function () 737api . nvim_set_var ( 'Nvim_color_expr' , 42 ) 738-- Used to error out due to failing to get callback. 739command ( 'hi clear NvimNumber' ) 740command ( 'hi NvimNumber guifg=Blue2' ) 741feed ( ':<C-r>=1' ) 742screen : expect ( [[ 743| 744{EOB:~ }|*6 745={NUM:1}^ | 746]] ) 747end ) 748it ( 'works correctly with non-ASCII and control characters' , function () 749command ( 'hi clear NvimStringBody' ) 750command ( 'hi clear NvimStringQuote' ) 751command ( 'hi clear NvimInvalid' ) 752command ( 'hi NvimStringQuote guifg=Blue3' ) 753command ( 'hi NvimStringBody guifg=Blue4' ) 754command ( 'hi NvimInvalid guifg=Red guibg=Blue' ) 755feed ( 'i<C-r>="«»"«»' ) 756screen : expect ( [[ 757| 758{EOB:~ }|*6 759={SQ:"}{SB:«»}{SQ:"}{E:«»}^ | 760]] ) 761feed ( '<C-c>' ) 762screen : expect ( [[ 763^ | 764{EOB:~ }|*6 765{M:-- INSERT --} | 766]] ) 767feed ( '<Esc>' ) 768screen : expect ( [[ 769^ | 770{EOB:~ }|*6 771| 772]] ) 773feed ( ':<C-\\>e"<C-v><C-x>"<C-v><C-x>' ) 774-- TODO(ZyX-I): Parser highlighting should not override special character 775-- highlighting. 776screen : expect ( [[ 777| 778{EOB:~ }|*6 779={SQ:"}{SB:^X}{SQ:"}{ERR:^X}^ | 780]] ) 781feed ( '<C-c>' ) 782screen : expect ( [[ 783| 784{EOB:~ }|*6 785:^ | 786]] ) 787fn . setreg ( 'a' , { '\192' } ) 788feed ( '<C-r>="<C-r><C-r>a"<C-r><C-r>a"foo"' ) 789screen : expect ( [[ 790| 791{EOB:~ }|*6 792={SQ:"}{SB:<c0>}{SQ:"}{E:<c0>"}{SB:foo}{E:"}^ | 793]] ) 794end ) 795end )