robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each , after_each , pending , finally = 6t . describe , t . it , t . before_each , t . after_each , t . pending , t . finally 7local clear , feed =n . clear , n . feed 8local eval =n . eval 9local eq =t . eq 10local neq =t . neq 11local command =n . command 12local set_method_error =n . set_method_error 13local api =n . api 14local async_meths =n . async_meths 15local nvim_prog =n . nvim_prog 16local testprg =n . testprg 17local exec =n . exec 18local exec_capture =n . exec_capture 19local exec_lua =n . exec_lua 20local poke_eventloop =n . poke_eventloop 21local assert_alive =n . assert_alive 22local retry =t . retry 23local is_os =t . is_os 24local fn =n . fn 25local skip =t . skip 26 27describe ( 'ui/ext_messages' , function () 28local screen 29local fname ='Xtest_functional_ui_messages_spec' 30 31before_each ( function () 32clear () 33screen =Screen . new ( 25 , 5 , { rgb =true , ext_messages =true , ext_popupmenu =true } ) 34screen : add_extra_attr_ids { 35[ 100 ] ={ undercurl =true , special =Screen . colors . Red } , 36[ 101 ] ={ foreground =Screen . colors . Magenta1 , bold =true } , 37} 38end ) 39after_each ( function () 40os . remove ( fname ) 41end ) 42 43it ( 'msg_show kinds' , function () 44feed ( 'iline 1\nline 2<esc>' ) 45 46-- confirm is now cmdline prompt 47feed ( ':echo confirm("test")<cr>' ) 48screen : expect ( { 49grid =[[ 50line 1 | 51line ^2 | 52{1:~ }|*3 53]] , 54cmdline ={ { content ={ { '' } } , hl ='MoreMsg' , pos =0 , prompt ='[O]k: ' } } , 55messages ={ { content ={ { 'test' , 6 , 'MoreMsg' } } , kind ='confirm' } } , 56} ) 57feed ( '<cr>' ) 58screen : expect ( { 59grid =[[ 60line 1 | 61line ^2 | 62{1:~ }|*3 63]] , 64messages ={ { content ={ { '1' } } , kind ='echo' } } , 65} ) 66 67-- :substitute confirm is now cmdline prompt 68feed ( ':%s/i/X/gc<cr>' ) 69screen : expect ( { 70grid =[[ 71l{2:i}ne 1 | 72l{10:i}ne ^2 | 73{1:~ }|*3 74]] , 75cmdline ={ 76{ 77content ={ { '' } } , 78hl ='Question' , 79pos =0 , 80prompt ='replace with X? (y)es/(n)o/(a)ll/(q)uit/(l)ast/scroll up(^E)/down(^Y)' , 81} , 82} , 83} ) 84feed ( 'nq' ) 85 86-- kind=wmsg (editing readonly file) 87local byte =t . is_os ( 'win' ) and 16 or 14 88local writemsg =( '"Xtest_functional_ui_messages_spec" [New] 2L, %dB written' ): format ( byte ) 89command ( 'write ' .. fname ) 90command ( 'set readonly nohls' ) 91feed ( 'G$x' ) 92screen : expect ( { 93grid =[[ 94line 1 | 95line^ | 96{1:~ }|*3 97]] , 98messages ={ 99{ 100content ={ { writemsg } } , 101history =true , 102id ='nvim.bufwrite "Xtest_functional_ui_messages_spec"' , 103kind ='progress' , 104} , 105{ 106content ={ { 'W10: Warning: Changing a readonly file' , 19 , 'WarningMsg' } } , 107history =true , 108kind ='wmsg' , 109} , 110} , 111} ) 112 113-- kind=wmsg ('wrapscan' after search reaches EOF) 114command ( 'silent undo' ) 115feed ( 'G$/i<CR>G$' ) 116screen : expect { 117grid =[[ 118line 1 | 119line ^2 | 120{1:~ }|*3 121]] , 122messages ={ 123{ content ={ { '/i ' } } , kind ='search_cmd' } , 124{ 125content ={ { 'search hit BOTTOM, continuing at TOP' , 19 , 'WarningMsg' } } , 126kind ='wmsg' , 127} , 128} , 129} 130 131-- kind=emsg after :throw 132feed ( ':throw "foo"<cr>' ) 133screen : expect { 134grid =[[ 135line 1 | 136line ^2 | 137{1:~ }|*3 138]] , 139messages ={ 140{ 141content ={ { 'Error in :\nE605: Exception not caught: foo' , 9 , 'ErrorMsg' } } , 142history =true , 143kind ='emsg' , 144} , 145} , 146} 147 148-- kind=quickfix after :cnext 149command ( "caddexpr [expand('%').':1:line1',expand('%').':2:line2']" ) 150feed ( ':cnext<CR>$' ) 151screen : expect { 152grid =[[ 153line 1 | 154line ^2 | 155{1:~ }|*3 156]] , 157messages ={ 158{ content ={ { '(2 of 2): line2' } } , history =true , kind ='quickfix' } , 159} , 160} 161 162-- search_cmd 163feed ( '?line<CR>G$' ) 164screen : expect ( { 165grid =[[ 166line 1 | 167line ^2 | 168{1:~ }|*3 169]] , 170messages ={ { content ={ { '?line ' } } , kind ='search_cmd' } } , 171} ) 172 173-- highlight 174feed ( 'G$:filter character highlight<CR>' ) 175screen : expect ( { 176grid =[[ 177line 1 | 178line ^2 | 179{1:~ }|*3 180]] , 181messages ={ 182{ 183content ={ 184{ '@character ' } , 185{ 'xxx' , 26 , '@character' } , 186{ ' ' } , 187{ 'links to' , 18 , 'Directory' } , 188{ ' Character\n@character.special ' } , 189{ 'xxx' , 16 , '@character.special' } , 190{ ' ' } , 191{ 'links to' , 18 , 'Directory' } , 192{ ' SpecialChar' } , 193} , 194kind ='list_cmd' , 195} , 196} , 197} ) 198 199-- undo 200feed ( 'u' ) 201screen : expect ( { 202grid =[[ 203^ | 204{1:~ }|*4 205]] , 206condition =function () 207local msg =screen . messages [ 1 ]. content [ 1 ][ 2 ]: gsub ( '%d seconds?' , '0 seconds' ) 208eq ( '2 fewer lines; before #1 0 seconds ago' , msg ) 209eq ( 'undo' , screen . messages [ 1 ]. kind ) 210screen . messages ={} 211end , 212} ) 213feed ( 'u' ) 214screen : expect ( { 215grid =[[ 216^ | 217{1:~ }|*4 218]] , 219messages ={ 220{ content ={ { 'Already at oldest change' } } , history =true , kind ='undo' } , 221} , 222} ) 223 224command ( 'silent redo | silent redo | redo' ) 225screen : expect ( { 226grid =[[ 227line 1 | 228line^ | 229{1:~ }|*3 230]] , 231messages ={ 232{ content ={ { 'Already at newest change' } } , history =true , kind ='undo' } , 233} , 234} ) 235 236-- kind=completion 237command ( 'set noshowmode' ) 238feed ( 'i<C-n>' ) 239screen : expect ( { 240grid =[[ 241line 1 | 242line^ | 243{1:~ }|*3 244]] , 245messages ={ { content ={ { 'The only match' } } , kind ='completion' } } , 246} ) 247feed ( '<Esc>l' ) 248command ( 'set showmode' ) 249 250-- kind=echoerr for nvim_echo() err 251feed ( ':call nvim_echo([["Error"], ["Message", "Special"]], 1, #{ err:1 })<CR>' ) 252screen : expect ( { 253grid =[[ 254line 1 | 255line^ | 256{1:~ }|*3 257]] , 258messages ={ 259{ 260content ={ { 'Error' , 9 , 'ErrorMsg' } , { 'Message' , 16 , 'Special' } } , 261history =true , 262kind ='echoerr' , 263} , 264} , 265} ) 266 267-- kind=verbose for nvim_echo() verbose 268feed ( ':call nvim_echo([["Verbose Message"]], 1, #{ verbose:1 })<CR>' ) 269screen : expect ( { 270grid =[[ 271line 1 | 272line^ | 273{1:~ }|*3 274]] , 275messages ={ 276{ content ={ { 'Verbose Message' } } , history =true , kind ='verbose' } , 277} , 278} ) 279 280feed ( ':call nvim_echo([["Foo"]], 1, #{ kind:"list_cmd" })<CR>' ) 281screen : expect ( { 282grid =[[ 283line 1 | 284line^ | 285{1:~ }|*3 286]] , 287messages ={ { content ={ { 'Foo' } } , history =true , kind ='list_cmd' } } , 288} ) 289 290-- kind=verbose for :verbose messages 291feed ( ':1verbose filter Diff[AC] hi<CR>' ) 292screen : expect ( { 293grid =[[ 294line 1 | 295line^ | 296{1:~ }|*3 297]] , 298messages ={ 299{ 300content ={ 301{ 'DiffAdd ' } , 302{ 'xxx' , 22 , 'DiffAdd' } , 303{ ' ' } , 304{ 'ctermbg=' , 18 , 'Directory' } , 305{ '81 ' } , 306{ 'guibg=' , 18 , 'Directory' } , 307{ 308'LightBlue\n\tLast set from Lua (run Nvim with -V1 for more details)\nDiffChange ' , 309} , 310{ 'xxx' , 4 , 'DiffChange' } , 311{ ' ' } , 312{ 'ctermbg=' , 18 , 'Directory' } , 313{ '225 ' } , 314{ 'guibg=' , 18 , 'Directory' } , 315{ 'LightMagenta\n\tLast set from Lua (run Nvim with -V1 for more details)' } , 316} , 317kind ='list_cmd' , 318} , 319} , 320} ) 321 322exec ( [[ 323set verbose=9 324augroup group1 325autocmd BufEnter * echoh "BufEnter" 326autocmd BufWinEnter * bdelete 327autocmd ExitPre pat1 foo 328autocmd ExitPre pat2 bar 329augroup END 330augroup group2 331autocmd ExitPre pat1 foo 332autocmd ExitPre pat2 bar 333augroup END 334]] ) 335feed ( ':edit! foo<CR>' ) 336screen : expect ( { 337grid =[[ 338line 1 | 339^line | 340{1:~ }|*3 341]] , 342messages ={ 343{ content ={ { 'finished sourcing nvim_exec2()' } } , history =true , kind ='verbose' } , 344{ 345content ={ { 'Executing BufEnter Autocommands for "*"' } } , 346history =true , 347kind ='verbose' , 348} , 349{ content ={ { 'autocommand echoh "BufEnter"' } } , history =true , kind ='verbose' } , 350{ content ={ { '\n' } } , kind ='' } , 351{ 352content ={ { 'Executing BufWinEnter Autocommands for "*"' } } , 353history =true , 354kind ='verbose' , 355} , 356{ content ={ { 'autocommand bdelete' } } , history =true , kind ='verbose' } , 357{ content ={ { '\n' } } , kind ='' } , 358} , 359} ) 360feed ( ':au ExitPre<CR>' ) 361screen : expect ( { 362grid =[[ 363line 1 | 364^line | 365{1:~ }|*3 366]] , 367messages ={ 368{ 369content ={ 370{ '--- Autocommands ---' , 101 , 'Title' } , 371{ '\n' } , 372{ 'group1' , 101 , 'Title' } , 373{ ' ' } , 374{ 'ExitPre' , 101 , 'Title' } , 375{ 376'\n pat1 foo\n\tLast set from anonymous :source line 5\n pat2 bar\n\tLast set from anonymous :source line 6\n' , 377} , 378{ 'group2' , 101 , 'Title' } , 379{ ' ' } , 380{ 'ExitPre' , 101 , 'Title' } , 381{ 382'\n pat1 foo\n\tLast set from anonymous :source line 9\n pat2 bar\n\tLast set from anonymous :source line 10' , 383} , 384} , 385kind ='list_cmd' , 386} , 387} , 388} ) 389command ( 'autocmd! group1' ) 390command ( 'autocmd! group2' ) 391command ( 'augroup! group1' ) 392command ( 'augroup! group2' ) 393command ( 'set verbose=0' ) 394 395n . add_builddir_to_rtp () 396feed ( ':help<CR>:tselect<CR>' ) 397screen : expect ( { 398grid =[[ 399^*help.txt* Nvim | 400| 401{3:help.txt [Help][-][RO] }| 402line | 403{2:<i_messages_spec [+][RO] }| 404]] , 405cmdline ={ 406{ 407content ={ { '' } } , 408pos =0 , 409-- Default vim.ui.select uses this prompt. 410prompt ='Type number and <Enter> (q or empty cancels): ' , 411} , 412} , 413-- Message depends on runtimepath, only test the static text... 414condition =function () 415for _ , msg in ipairs ( screen . messages ) do 416eq ( false , msg . history ) 417eq ( 'confirm' , msg . kind ) 418local text ='' -- Concatenate all chunks. 419for _ , chunk in ipairs ( msg . content ) do 420text =text .. ( # chunk >= 2 and chunk [ 2 ] or chunk [ 1 ]) 421end 422t . matches ( '^Select a tag:\n' , text ) 423t . matches ( '1: > F%s+help%.txt%s+' , text ) 424end 425screen . messages ={} 426end , 427} ) 428feed ( '<CR>:bdelete<CR>$' ) 429 430-- kind=shell for :!cmd messages 431local cmd =t . is_os ( 'win' ) and 'echo stdout& echo stderr>&2& exit 3' 432or '{ echo stdout; echo stderr >&2; exit 3; }' 433feed (( ':!%s<CR>' ): format ( cmd )) 434screen : expect ( { 435grid =[[ 436line 1 | 437line^ | 438{1:~ }|*3 439]] , 440messages ={ 441{ 442content ={ { ( ':!%s\r\n[No write since last change]\n' ): format ( cmd ) } } , 443kind ='shell_cmd' , 444} , 445{ 446content ={ { ( 'stdout%s\n' ): format ( t . is_os ( 'win' ) and '\r' or '' ), 'StdoutMsg' } } , 447kind ='shell_out' , 448append =true , 449} , 450{ 451content ={ { ( 'stderr%s\n' ): format ( t . is_os ( 'win' ) and '\r' or '' ), 9 , 'StderrMsg' } } , 452kind ='shell_err' , 453append =true , 454} , 455{ content ={ { 'shell returned 3' } } , kind ='shell_ret' } , 456} , 457} ) 458 459feed ( ':registers .<CR>' ) 460screen : expect ( { 461grid =[[ 462line 1 | 463line^ | 464{1:~ }|*3 465]] , 466messages ={ 467{ 468content ={ { 'Type Name Content' , 101 , 'Title' } , { '\n c ". ' } } , 469kind ='list_cmd' , 470} , 471} , 472} ) 473 474feed ( ':au ChanInfo * foo<CR>:au ChanInfo<CR>' ) 475screen : expect ( { 476grid =[[ 477line 1 | 478line^ | 479{1:~ }|*3 480]] , 481messages ={ 482{ 483content ={ 484{ '--- Autocommands ---' , 101 , 'Title' } , 485{ '\n' } , 486{ 'ChanInfo' , 101 , 'Title' } , 487{ '\n * foo' } , 488} , 489kind ='list_cmd' , 490} , 491} , 492} ) 493 494feed ( ':1,2p<CR>' ) 495screen : expect ( { 496grid =[[ 497line 1 | 498^line | 499{1:~ }|*3 500]] , 501messages ={ { content ={ { 'line 1\nline ' } } , kind ='list_cmd' } } , 502} ) 503 504-- single message for :global command #37726 505feed ( ':g/line<CR>' ) 506screen : expect ( { 507grid =[[ 508line 1 | 509^line | 510{1:~ }|*3 511]] , 512messages ={ { content ={ { 'line 1\nline ' } } , kind ='list_cmd' } } , 513} ) 514 515command ( 'command Foo Bar' ) 516feed ( ':command<CR>' ) 517screen : expect ( { 518grid =[[ 519line 1 | 520^line | 521{1:~ }|*3 522]] , 523messages ={ 524{ 525content ={ 526{ ' Name Args Address Complete Definition' , 101 , 'Title' } , 527{ '\n ' } , 528{ 'Foo' , 18 , 'Directory' } , 529{ ' 0 Bar' } , 530} , 531kind ='list_cmd' , 532} , 533} , 534} ) 535 536feed ( ':colorscheme<CR>' ) 537screen : expect ( { 538grid =[[ 539line 1 | 540^line | 541{1:~ }|*3 542]] , 543messages ={ { content ={ { 'default' } } , history =true , kind ='list_cmd' } } , 544} ) 545 546feed ( ':version<CR>' ) 547screen : expect ( { 548grid =[[ 549line 1 | 550^line | 551{1:~ }|*3 552]] , 553condition =function () 554eq ( 'list_cmd' , screen . messages [ 1 ]. kind ) 555screen . messages ={} -- Ignore build dependent :version content 556end , 557} ) 558 559-- 3 empty message events, not for an empty chunk after a non-printable character 560feed ( ':echo "foo\\n" | echo | echom "" | lua print()<CR>' ) 561screen : expect ( { 562grid =[[ 563line 1 | 564^line | 565{1:~ }|*3 566]] , 567messages ={ 568{ content ={ { 'foo\n' } } , kind ='echo' } , 569{ content ={} , kind ='empty' } , 570{ content ={} , kind ='empty' } , 571{ content ={} , kind ='empty' } , 572} , 573} ) 574 575-- No empty message event for empty option value 576feed ( ':set foldclose<CR>' ) 577screen : expect ( { 578grid =[[ 579line 1 | 580^line | 581{1:~ }|*3 582]] , 583messages ={ { content ={ { ' foldclose=' } } , history =true , kind ='list_cmd' } } , 584} ) 585 586-- Indent message 587feed ( 'A2\nline 3<Esc>gg=G' ) 588screen : expect ( { 589grid =[[ 590^line 1 | 591line 2 | 592line 3 | 593{1:~ }|*2 594]] , 595messages ={ 596{ 597content ={ { '3 lines indented ' } } , 598kind ='progress' , 599id ='nvim.indent' , 600history =true , 601} , 602} , 603} ) 604end ) 605 606it ( ':echoerr' , function () 607feed ( ':echoerr "raa"<cr>' ) 608screen : expect { 609grid =[[ 610^ | 611{1:~ }|*4 612]] , 613messages ={ { content ={ { 'raa' , 9 , 'ErrorMsg' } } , history =true , kind ='echoerr' } } , 614} 615 616-- cmdline in a later input cycle clears error message 617feed ( ':' ) 618screen : expect { 619grid =[[ 620^ | 621{1:~ }|*4 622]] , 623cmdline ={ { firstc =':' , content ={ { '' } } , pos =0 } } , 624} 625 626feed ( 'echoerr "bork" | echoerr "fail"<cr>' ) 627screen : expect { 628grid =[[ 629^ | 630{1:~ }|*4 631]] , 632messages ={ 633{ content ={ { 'bork' , 9 , 'ErrorMsg' } } , history =true , kind ='echoerr' } , 634{ content ={ { 'fail' , 9 , 'ErrorMsg' } } , history =true , kind ='echoerr' } , 635} , 636} 637 638feed ( ':echoerr "extrafail"<cr>' ) 639screen : expect { 640grid =[[ 641^ | 642{1:~ }|*4 643]] , 644messages ={ 645{ 646content ={ { 'extrafail' , 9 , 'ErrorMsg' } } , 647history =true , 648kind ='echoerr' , 649} , 650} , 651} 652 653-- cmdline without interleaving wait/display keeps the error message 654feed ( ':echoerr "problem" | let x = input("foo> ")<cr>' ) 655screen : expect { 656grid =[[ 657^ | 658{1:~ }|*4 659]] , 660messages ={ 661{ content ={ { 'problem' , 9 , 'ErrorMsg' } } , history =true , kind ='echoerr' } , 662} , 663cmdline ={ { prompt ='foo> ' , content ={ { '' } } , pos =0 } } , 664} 665 666feed ( 'solution<cr>' ) 667screen : expect_unchanged () 668eq ( 'solution' , eval ( 'x' )) 669 670feed ( ':messages<cr>' ) 671screen : expect { 672grid =[[ 673^ | 674{1:~ }|*4 675]] , 676msg_history ={ 677{ kind ='echoerr' , content ={ { 'raa' , 9 , 'ErrorMsg' } } } , 678{ kind ='echoerr' , content ={ { 'bork' , 9 , 'ErrorMsg' } } } , 679{ kind ='echoerr' , content ={ { 'fail' , 9 , 'ErrorMsg' } } } , 680{ kind ='echoerr' , content ={ { 'extrafail' , 9 , 'ErrorMsg' } } } , 681{ kind ='echoerr' , content ={ { 'problem' , 9 , 'ErrorMsg' } } } , 682} , 683} 684end ) 685 686it ( ':echoerr multiline' , function () 687exec_lua ( [[vim.g.multi = table.concat({ "bork", "fail" }, "\n")]] ) 688feed ( ':echoerr g:multi<cr>' ) 689screen : expect { 690grid =[[ 691^ | 692{1:~ }|*4 693]] , 694messages ={ 695{ 696content ={ { 'bork\nfail' , 9 , 'ErrorMsg' } } , 697history =true , 698kind ='echoerr' , 699} , 700} , 701} 702 703feed ( ':messages<cr>' ) 704screen : expect { 705grid =[[ 706^ | 707{1:~ }|*4 708]] , 709msg_history ={ { content ={ { 'bork\nfail' , 9 , 'ErrorMsg' } } , kind ='echoerr' } } , 710} 711end ) 712 713it ( 'shortmess-=S' , function () 714command ( 'set shortmess-=S' ) 715feed ( 'iline 1\nline 2<esc>' ) 716 717feed ( '/line<cr>' ) 718screen : expect { 719grid =[[ 720{10:^line} 1 | 721{10:line} 2 | 722{1:~ }|*3 723]] , 724messages ={ { content ={ { '/line W [1/2]' } } , kind ='search_count' } } , 725} 726 727feed ( 'n' ) 728screen : expect { 729grid =[[ 730{10:line} 1 | 731{10:^line} 2 | 732{1:~ }|*3 733]] , 734messages ={ { content ={ { '/line [2/2]' } } , kind ='search_count' } } , 735} 736end ) 737 738it ( "doesn't crash with column adjustment #10069" , function () 739feed ( ':let [x,y] = [1,2]<cr>' ) 740feed ( ':let x y<cr>' ) 741screen : expect ( { 742grid =[[ 743^ | 744{1:~ }|*4 745]] , 746messages ={ 747{ 748content ={ { 'x #1\ny #2' } } , 749kind ='list_cmd' , 750} , 751} , 752} ) 753end ) 754 755it ( '&showmode' , function () 756command ( 'imap <f2> <cmd>echomsg "stuff"<cr>' ) 757feed ( 'i' ) 758screen : expect { 759grid =[[ 760^ | 761{1:~ }|*4 762]] , 763showmode ={ { '-- INSERT --' , 5 , 'ModeMsg' } } , 764} 765 766feed ( 'alphpabet<cr>alphanum<cr>' ) 767screen : expect { 768grid =[[ 769alphpabet | 770alphanum | 771^ | 772{1:~ }|*2 773]] , 774showmode ={ { '-- INSERT --' , 5 , 'ModeMsg' } } , 775} 776 777feed ( '<c-x>' ) 778screen : expect { 779grid =[[ 780alphpabet | 781alphanum | 782^ | 783{1:~ }|*2 784]] , 785showmode ={ { '-- ^X mode (^]^D^E^F^I^K^L^N^O^P^Rs^U^V^Y)' , 5 , 'ModeMsg' } } , 786} 787 788feed ( '<c-p>' ) 789screen : expect { 790grid =[[ 791alphpabet | 792alphanum | 793alphanum^ | 794{1:~ }|*2 795]] , 796popupmenu ={ 797anchor ={ 1 , 2 , 0 } , 798items ={ { 'alphpabet' , '' , '' , '' } , { 'alphanum' , '' , '' , '' } } , 799pos =1 , 800} , 801showmode ={ 802{ '-- Keyword Local completion (^N^P) ' , 5 , 'ModeMsg' } , 803{ 'match 1 of 2' , 6 , 'Question' } , 804} , 805} 806 807-- echomsg and showmode don't overwrite each other, this is the same 808-- as the TUI behavior with cmdheight=2 or larger. 809feed ( '<f2>' ) 810screen : expect { 811grid =[[ 812alphpabet | 813alphanum | 814alphanum^ | 815{1:~ }|*2 816]] , 817popupmenu ={ 818anchor ={ 1 , 2 , 0 } , 819items ={ { 'alphpabet' , '' , '' , '' } , { 'alphanum' , '' , '' , '' } } , 820pos =1 , 821} , 822messages ={ { content ={ { 'stuff' } } , history =true , kind ='echomsg' } } , 823showmode ={ 824{ '-- Keyword Local completion (^N^P) ' , 5 , 'ModeMsg' } , 825{ 'match 1 of 2' , 6 , 'Question' } , 826} , 827} 828 829feed ( '<c-p>' ) 830screen : expect { 831grid =[[ 832alphpabet | 833alphanum | 834alphpabet^ | 835{1:~ }|*2 836]] , 837popupmenu ={ 838anchor ={ 1 , 2 , 0 } , 839items ={ { 'alphpabet' , '' , '' , '' } , { 'alphanum' , '' , '' , '' } } , 840pos =0 , 841} , 842showmode ={ 843{ '-- Keyword Local completion (^N^P) ' , 5 , 'ModeMsg' } , 844{ 'match 2 of 2' , 6 , 'Question' } , 845} , 846} 847 848feed ( '<esc>:messages<cr>' ) 849screen : expect { 850grid =[[ 851alphpabet | 852alphanum | 853alphpabe^t | 854{1:~ }|*2 855]] , 856msg_history ={ { content ={ { 'stuff' } } , kind ='echomsg' } } , 857} 858end ) 859 860it ( '&showmode with macro-recording message' , function () 861feed ( 'qq' ) 862screen : expect { 863grid =[[ 864^ | 865{1:~ }|*4 866]] , 867showmode ={ { 'recording @q' , 5 , 'ModeMsg' } } , 868} 869 870feed ( 'i' ) 871screen : expect { 872grid =[[ 873^ | 874{1:~ }|*4 875]] , 876showmode ={ { '-- INSERT --recording @q' , 5 , 'ModeMsg' } } , 877} 878 879feed ( '<esc>' ) 880screen : expect { 881grid =[[ 882^ | 883{1:~ }|*4 884]] , 885showmode ={ { 'recording @q' , 5 , 'ModeMsg' } } , 886} 887 888feed ( 'q' ) 889screen : expect ( [[ 890^ | 891{1:~ }|*4 892]] ) 893end ) 894 895it ( 'shows macro-recording message with &noshowmode' , function () 896command ( 'set noshowmode' ) 897feed ( 'qq' ) 898-- also check mode to avoid immediate success 899screen : expect { 900grid =[[ 901^ | 902{1:~ }|*4 903]] , 904showmode ={ { 'recording @q' , 5 , 'ModeMsg' } } , 905mode ='normal' , 906} 907 908feed ( 'i' ) 909screen : expect { 910grid =[[ 911^ | 912{1:~ }|*4 913]] , 914showmode ={ { 'recording @q' , 5 , 'ModeMsg' } } , 915mode ='insert' , 916} 917 918feed ( '<esc>' ) 919screen : expect { 920grid =[[ 921^ | 922{1:~ }|*4 923]] , 924showmode ={ { 'recording @q' , 5 , 'ModeMsg' } } , 925mode ='normal' , 926} 927 928feed ( 'q' ) 929screen : expect { 930grid =[[ 931^ | 932{1:~ }|*4 933]] , 934mode ='normal' , 935} 936end ) 937 938it ( "supports 'showcmd' and 'ruler(format)'" , function () 939command ( 'set showcmd ruler rulerformat=%12(%l,%c%V%=%P%)' ) 940command ( 'hi link MsgArea ErrorMsg' ) 941screen : expect ( { 942grid =[[ 943^ | 944{1:~ }|*4 945]] , 946ruler ={ { '0,0-1 All' , 9 , 'MsgArea' } } , 947} ) 948command ( 'hi clear MsgArea' ) 949feed ( 'i' ) 950screen : expect { 951grid =[[ 952^ | 953{1:~ }|*4 954]] , 955showmode ={ { '-- INSERT --' , 5 , 'ModeMsg' } } , 956ruler ={ { '0,1 All' , 'MsgArea' } } , 957} 958feed ( 'abcde<cr>12345<esc>' ) 959screen : expect { 960grid =[[ 961abcde | 9621234^5 | 963{1:~ }|*3 964]] , 965ruler ={ { '2,5 All' , 'MsgArea' } } , 966} 967feed ( 'd' ) 968screen : expect { 969grid =[[ 970abcde | 9711234^5 | 972{1:~ }|*3 973]] , 974showcmd ={ { 'd' } } , 975ruler ={ { '2,5 All' , 'MsgArea' } } , 976} 977feed ( '<esc>^' ) 978screen : expect { 979grid =[[ 980abcde | 981^12345 | 982{1:~ }|*3 983]] , 984ruler ={ { '2,1 All' , 'MsgArea' } } , 985} 986feed ( '<c-v>k2l' ) 987screen : expect ( { 988grid =[[ 989{17:ab^c}de | 990{17:123}45 | 991{1:~ }|*3 992]] , 993showmode ={ { '-- VISUAL BLOCK --' , 5 , 'ModeMsg' } } , 994showcmd ={ { '2x3' } } , 995ruler ={ { '1,3 All' , 'MsgArea' } } , 996} ) 997feed ( 'o<esc>d' ) 998screen : expect { 999grid =[[ 1000abcde | 1001^12345 | 1002{1:~ }|*3 1003]] , 1004showcmd ={ { 'd' } } , 1005ruler ={ { '2,1 All' , 'MsgArea' } } , 1006} 1007feed ( 'i' ) 1008screen : expect { 1009grid =[[ 1010abcde | 1011^12345 | 1012{1:~ }|*3 1013]] , 1014showcmd ={ { 'di' } } , 1015ruler ={ { '2,1 All' , 'MsgArea' } } , 1016} 1017feed ( 'w' ) 1018screen : expect { 1019grid =[[ 1020abcde | 1021^ | 1022{1:~ }|*3 1023]] , 1024ruler ={ { '2,0-1 All' , 'MsgArea' } } , 1025} 1026command ( 'set rulerformat=Foo%#ErrorMsg#Bar' ) 1027screen : expect ( { 1028grid =[[ 1029abcde | 1030^ | 1031{1:~ }|*3 1032]] , 1033ruler ={ { 'Foo' , 'MsgArea' } , { 'Bar' , 9 , 'ErrorMsg' } } , 1034} ) 1035command ( 'set rulerformat=' ) 1036 1037-- when ruler is part of statusline it is not externalized. 1038-- this will be added as part of future ext_statusline support 1039command ( 'set laststatus=2' ) 1040screen : expect ( [[ 1041abcde | 1042^ | 1043{1:~ }|*2 1044{3:<] [+] 2,0-1 All}| 1045]] ) 1046-- ruler of float is not part of statusline and is cleared when leaving the float #37649. 1047command ( 'set rulerformat=foo' ) 1048api . nvim_open_win ( 0 , true , { relative ='editor' , row =1 , col =1 , width =10 , height =10 } ) 1049screen : expect ( { 1050grid =[[ 1051a{4:abcde } | 1052{4:^ } | 1053{1:~}{11:~ }{1: }|*2 1054{2:[}{11:~ }{2:+] foo}| 1055]] , 1056ruler ={ { 'foo' , 'MsgArea' } } , 1057} ) 1058command ( 'wincmd p' ) 1059screen : expect ( [[ 1060a{4:abcde } | 1061^ {4: } | 1062{1:~}{11:~ }{1: }|*2 1063{3:[}{11:~ }{3:+] foo}| 1064]] ) 1065end ) 1066 1067it ( 'keeps history of message of different kinds' , function () 1068feed ( ':echomsg "howdy"<cr>' ) 1069screen : expect { 1070grid =[[ 1071^ | 1072{1:~ }|*4 1073]] , 1074messages ={ { content ={ { 'howdy' } } , history =true , kind ='echomsg' } } , 1075} 1076 1077-- always test a message without kind. If this one gets promoted to a 1078-- category, add a new message without kind. 1079feed ( '<c-c>' ) 1080screen : expect { 1081grid =[[ 1082^ | 1083{1:~ }|*4 1084]] , 1085messages ={ 1086{ 1087content ={ { 'Type :qa and press <Enter> to exit Nvim' } } , 1088history =true , 1089kind ='' , 1090} , 1091} , 1092} 1093 1094feed ( ':echoerr "bork"<cr>' ) 1095screen : expect { 1096grid =[[ 1097^ | 1098{1:~ }|*4 1099]] , 1100messages ={ 1101{ content ={ { 'bork' , 9 , 'ErrorMsg' } } , history =true , kind ='echoerr' } , 1102} , 1103} 1104 1105feed ( ':echo "xyz"<cr>' ) 1106screen : expect { 1107grid =[[ 1108^ | 1109{1:~ }|*4 1110]] , 1111messages ={ { content ={ { 'xyz' } } , kind ='echo' } } , 1112} 1113 1114feed ( ':call nosuchfunction()<cr>' ) 1115screen : expect { 1116grid =[[ 1117^ | 1118{1:~ }|*4 1119]] , 1120messages ={ 1121{ 1122content ={ { 'E117: Unknown function: nosuchfunction' , 9 , 'ErrorMsg' } } , 1123history =true , 1124kind ='emsg' , 1125} , 1126} , 1127} 1128 1129feed ( ':messages<cr>' ) 1130screen : expect { 1131grid =[[ 1132^ | 1133{1:~ }|*4 1134]] , 1135msg_history ={ 1136{ kind ='echomsg' , content ={ { 'howdy' } } } , 1137{ kind ='' , content ={ { 'Type :qa and press <Enter> to exit Nvim' } } } , 1138{ kind ='echoerr' , content ={ { 'bork' , 9 , 'ErrorMsg' } } } , 1139{ 1140kind ='emsg' , 1141content ={ { 'E117: Unknown function: nosuchfunction' , 9 , 'ErrorMsg' } } , 1142} , 1143} , 1144} 1145end ) 1146 1147it ( "implies ext_cmdline but allows changing 'cmdheight'" , function () 1148eq ( 0 , eval ( '&cmdheight' )) 1149feed ( ':set cmdheight=1' ) 1150screen : expect { 1151grid =[[ 1152^ | 1153{1:~ }|*4 1154]] , 1155cmdline ={ { content ={ { 'set cmdheight=1' } } , firstc =':' , pos =15 } } , 1156} 1157 1158feed ( '<cr>' ) 1159screen : expect ( [[ 1160^ | 1161{1:~ }|*3 1162| 1163]] ) 1164eq ( 1 , eval ( '&cmdheight' )) 1165 1166feed ( ':set cmdheight=0' ) 1167screen : expect { 1168grid =[[ 1169^ | 1170{1:~ }|*3 1171| 1172]] , 1173cmdline ={ { content ={ { 'set cmdheight=0' } } , firstc =':' , pos =15 } } , 1174} 1175feed ( '<cr>' ) 1176screen : expect ( [[ 1177^ | 1178{1:~ }|*4 1179]] ) 1180eq ( 0 , eval ( '&cmdheight' )) 1181end ) 1182 1183it ( 'supports multiline messages from lua' , function () 1184feed ( ':lua error("such\\nmultiline\\nerror")<cr>' ) 1185screen : expect { 1186grid =[[ 1187^ | 1188{1:~ }|*4 1189]] , 1190messages ={ 1191{ 1192content ={ 1193{ 1194[[E5108: Lua: [string ":lua"]:1: such 1195multiline 1196error 1197stack traceback: 1198[C]: in function 'error' 1199[string ":lua"]:1: in main chunk]] , 12009 , 1201'ErrorMsg' , 1202} , 1203} , 1204history =true , 1205kind ='lua_error' , 1206} , 1207} , 1208} 1209end ) 1210 1211it ( 'supports multiline messages from rpc' , function () 1212feed ( ':call rpcrequest(1, "test_method")<cr>' ) 1213 1214screen : expect { 1215grid =[[ 1216^ | 1217{1:~ }|*4 1218]] , 1219messages ={ 1220{ 1221content ={ 1222{ 1223"Invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage" , 12249 , 1225'ErrorMsg' , 1226} , 1227} , 1228history =true , 1229kind ='rpc_error' , 1230} , 1231} , 1232request_cb =function ( name ) 1233if name == 'test_method' then 1234set_method_error ( 'complete\nerror\n\nmessage' ) 1235end 1236end , 1237} 1238end ) 1239 1240it ( 'supports multiline messages for :map' , function () 1241command ( 'mapclear' ) 1242command ( 'nmap Y y$' ) 1243command ( 'nmap Q @@' ) 1244command ( 'nnoremap j k' ) 1245feed ( ':map<cr>' ) 1246 1247screen : expect { 1248grid =[[ 1249^ | 1250{1:~ }|*4 1251]] , 1252messages ={ 1253{ 1254content ={ 1255{ 'n Q @@\nn Y y$\nn j ' } , 1256{ '*' , 18 , 'SpecialKey' } , 1257{ ' k' } , 1258} , 1259kind ='list_cmd' , 1260} , 1261} , 1262} 1263end ) 1264 1265it ( 'wildmode=list' , function () 1266screen : try_resize ( 25 , 7 ) 1267screen : set_option ( 'ext_popupmenu' , false ) 1268 1269command ( 'set wildmenu wildmode=list' ) 1270feed ( ':set wildm<tab>' ) 1271screen : expect { 1272grid =[[ 1273^ | 1274{1:~ }|*6 1275]] , 1276messages ={ { content ={ { 'wildmenu wildmode\n' } } , kind ='wildlist' } } , 1277cmdline ={ { firstc =':' , content ={ { 'set wildm' } } , pos =9 } } , 1278} 1279end ) 1280 1281it ( 'hides prompt_for_number messages' , function () 1282command ( 'set spell' ) 1283feed ( 'ihelllo<esc>' ) 1284 1285feed ( 'z=' ) 1286screen : expect ( { 1287grid =[[ 1288{100:helll^o} | 1289{1:~ }|*4 1290]] , 1291cmdline ={ 1292{ 1293content ={ { '' } } , 1294pos =0 , 1295prompt ='Type number and <Enter> (q or empty cancels): ' , 1296} , 1297} , 1298messages ={ 1299{ 1300content ={ { 'Change "helllo" to:\n1: "Hello"\n2: "Hallo"\n3: "Hullo"' } } , 1301kind ='confirm' , 1302} , 1303} , 1304} ) 1305 1306feed ( '1' ) 1307screen : expect ( { 1308grid =[[ 1309{100:helll^o} | 1310{1:~ }|*4 1311]] , 1312cmdline ={ 1313{ 1314content ={ { '1' } } , 1315pos =1 , 1316prompt ='Type number and <Enter> (q or empty cancels): ' , 1317} , 1318} , 1319} ) 1320 1321feed ( '<cr>' ) 1322screen : expect ( [[ 1323^Hello | 1324{1:~ }|*4 1325]] ) 1326 1327async_meths . nvim_command ( "let g:n = inputlist(['input0', 'input1'])" ) 1328screen : expect ( { 1329grid =[[ 1330^Hello | 1331{1:~ }|*4 1332]] , 1333cmdline ={ 1334{ 1335content ={ { '' } } , 1336pos =0 , 1337prompt ='Type number and <Enter> (q or empty cancels): ' , 1338} , 1339} , 1340messages ={ { content ={ { 'input0\ninput1' } } , kind ='confirm' } } , 1341} ) 1342 1343feed ( '42<CR>' ) 1344screen : expect ( { 1345grid =[[ 1346^Hello | 1347{1:~ }|*4 1348]] , 1349unchanged =true , 1350} ) 1351eq ( 42 , eval ( 'g:n' )) 1352end ) 1353 1354it ( 'supports nvim_echo messages with multiple attrs' , function () 1355local chunks ={ { 'wow, ' , 'Search' } , { 'such\n\nvery ' , 'ErrorMsg' } , { 'color' , 'LineNr' } } 1356async_meths . nvim_echo ( chunks , true , {} ) 1357screen : expect { 1358grid =[[ 1359^ | 1360{1:~ }|*4 1361]] , 1362messages ={ 1363{ 1364content ={ 1365{ 'wow, ' , 10 , 'Search' } , 1366{ 'such\n\nvery ' , 9 , 'ErrorMsg' } , 1367{ 'color' , 8 , 'LineNr' } , 1368} , 1369history =true , 1370kind ='echomsg' , 1371} , 1372} , 1373} 1374 1375feed ':ls<cr>' 1376screen : expect { 1377grid =[[ 1378^ | 1379{1:~ }|*4 1380]] , 1381messages ={ 1382{ content ={ { ' 1 %a "[No Name]" line 1' } } , kind ='list_cmd' } , 1383} , 1384} 1385 1386feed ':messages<cr>' 1387screen : expect { 1388grid =[[ 1389^ | 1390{1:~ }|*4 1391]] , 1392msg_history ={ 1393{ 1394content ={ 1395{ 'wow, ' , 10 , 'Search' } , 1396{ 'such\n\nvery ' , 9 , 'ErrorMsg' } , 1397{ 'color' , 8 , 'LineNr' } , 1398} , 1399kind ='echomsg' , 1400} , 1401} , 1402} 1403end ) 1404 1405it ( 'does not truncate messages' , function () 1406command ( 'write ' .. fname ) 1407screen : expect ( { 1408messages ={ 1409{ 1410content ={ { string . format ( '"%s" [New] 0L, 0B written' , fname ) } } , 1411kind ='progress' , 1412id ='nvim.bufwrite "Xtest_functional_ui_messages_spec"' , 1413history =true , 1414} , 1415} , 1416} ) 1417end ) 1418 1419it ( 'does not do showmode unnecessarily #29086' , function () 1420local screen_showmode =screen . _handle_msg_showmode 1421local showmode =0 1422screen . _handle_msg_showmode =function ( ... ) 1423screen_showmode ( ... ) 1424showmode =showmode + 1 1425end 1426screen : expect ( [[ 1427^ | 1428{1:~ }|*4 1429]] ) 1430eq ( 0 , showmode ) 1431feed ( 'i' ) 1432screen : expect ( { 1433grid =[[ 1434^ | 1435{1:~ }|*4 1436]] , 1437showmode ={ { '-- INSERT --' , 5 , 'ModeMsg' } } , 1438} ) 1439eq ( 2 , showmode ) 1440command ( 'set noshowmode' ) 1441feed ( '<Esc>' ) 1442screen : expect ( [[ 1443^ | 1444{1:~ }|*4 1445]] ) 1446eq ( 3 , showmode ) 1447feed ( 'i' ) 1448screen : expect_unchanged () 1449eq ( 3 , showmode ) 1450end ) 1451 1452it ( 'emits single message for multiline print())' , function () 1453exec_lua ( [[print("foo\nbar\nbaz")]] ) 1454screen : expect ( { 1455grid =[[ 1456^ | 1457{1:~ }|*4 1458]] , 1459messages ={ { content ={ { 'foo\nbar\nbaz' } } , history =true , kind ='lua_print' } } , 1460} ) 1461exec_lua ( [[print(vim.inspect({ foo = "bar" }))]] ) 1462screen : expect ( { 1463grid =[[ 1464^ | 1465{1:~ }|*4 1466]] , 1467messages ={ 1468{ content ={ { '{\n foo = "bar"\n}' } } , history =true , kind ='lua_print' } , 1469} , 1470} ) 1471exec_lua ( [[vim.print({ foo = "bar" })]] ) 1472screen : expect ( { 1473grid =[[ 1474^ | 1475{1:~ }|*4 1476]] , 1477messages ={ 1478{ content ={ { '{\n foo = "bar"\n}' } } , history =true , kind ='lua_print' } , 1479} , 1480} ) 1481end ) 1482 1483it ( 'ruler redraw does not crash due to double grid_line_start()' , function () 1484exec_lua ( [[ 1485local ns = vim.api.nvim_create_namespace('') 1486vim.ui_attach(ns, { ext_messages = true }, function(event, ...) 1487if event == 'msg_ruler' then 1488vim.api.nvim__redraw({ flush = true }) 1489end 1490end) 1491vim.o.ruler = true 1492vim.o.laststatus = 0 1493]] ) 1494feed ( 'i' ) 1495n . assert_alive () 1496end ) 1497 1498it ( ':digraph contains newlines' , function () 1499command ( 'digraph' ) 1500screen : expect ( { 1501condition =function () 1502local nl =0 1503eq ( 'list_cmd' , screen . messages [ 1 ]. kind ) 1504for _ , chunk in ipairs ( screen . messages [ 1 ]. content ) do 1505nl =nl + ( chunk [ 2 ]: find ( '\n' ) and 1 or 0 ) 1506end 1507eq ( 683 , nl ) 1508screen . messages ={} 1509end , 1510} ) 1511end ) 1512 1513it ( 'g< mapping shows recent messages' , function () 1514feed ( ':echo "foo" | echo "bar" | echon "baz"<CR>' ) 1515screen : expect ( { 1516grid =[[ 1517^ | 1518{1:~ }|*4 1519]] , 1520messages ={ 1521{ content ={ { 'foo' } } , kind ='echo' } , 1522{ content ={ { 'bar' } } , kind ='echo' } , 1523{ content ={ { 'baz' } } , kind ='echo' , append =true } , 1524} , 1525} ) 1526feed ( 'g<lt>' ) 1527screen : expect ( { 1528grid =[[ 1529^ | 1530{1:~ }|*4 1531]] , 1532msg_history ={ 1533prev_cmd =true , 1534{ content ={ { 'foo' } } , kind ='echo' } , 1535{ content ={ { 'bar' } } , kind ='echo' } , 1536{ content ={ { 'baz' } } , kind ='echo' , append =true } , 1537} , 1538} ) 1539feed ( '@@' ) 1540screen : expect ( { 1541grid =[[ 1542^ | 1543{1:~ }|*4 1544]] , 1545messages ={ 1546{ 1547content ={ { 'E748: No previously used register' , 9 , 'ErrorMsg' } } , 1548history =true , 1549kind ='emsg' , 1550} , 1551} , 1552} ) 1553feed ( 'g<lt>' ) 1554screen : expect ( { 1555grid =[[ 1556^ | 1557{1:~ }|*4 1558]] , 1559msg_history ={ 1560prev_cmd =true , 1561{ content ={ { 'E748: No previously used register' , 9 , 'ErrorMsg' } } , kind ='emsg' } , 1562} , 1563} ) 1564end ) 1565 1566it ( 'single event for multiple :set options' , function () 1567command ( 'set sw ts sts' ) 1568screen : expect ( { 1569grid =[[ 1570^ | 1571{1:~ }|*4 1572]] , 1573messages ={ 1574{ content ={ { ' shiftwidth=8\n tabstop=8\n softtabstop=0' } } , kind ='list_cmd' } , 1575} , 1576} ) 1577end ) 1578 1579it ( 'clears showmode after insert_expand mode' , function () 1580feed ( 'i<C-N>' ) 1581screen : expect ( { 1582grid =[[ 1583^ | 1584{1:~ }|*4 1585]] , 1586showmode ={ 1587{ '-- Keyword completion (^N^P) ' , 5 , 'ModeMsg' } , 1588{ 'Pattern not found' , 9 , 'ErrorMsg' } , 1589} , 1590} ) 1591feed ( '<Esc>' ) 1592screen : expect ( [[ 1593^ | 1594{1:~ }|*4 1595]] ) 1596end ) 1597 1598it ( ':echon sets append' , function () 1599command ( 'echo "foo" | echon " bar" | echon " baz"' ) 1600screen : expect ( { 1601grid =[[ 1602^ | 1603{1:~ }|*4 1604]] , 1605messages ={ 1606{ content ={ { 'foo' } } , kind ='echo' } , 1607{ content ={ { ' bar' } } , kind ='echo' , append =true } , 1608{ content ={ { ' baz' } } , kind ='echo' , append =true } , 1609} , 1610} ) 1611end ) 1612 1613it ( 'can capture execute("messages"))' , function () 1614feed ( '@@' ) 1615screen : expect ( { 1616grid =[[ 1617^ | 1618{1:~ }|*4 1619]] , 1620messages ={ 1621{ 1622content ={ { 'E748: No previously used register' , 9 , 'ErrorMsg' } } , 1623history =true , 1624kind ='emsg' , 1625} , 1626} , 1627} ) 1628feed ( ':let msg = execute("messages")<CR>' ) 1629screen : expect_unchanged () 1630eq ( 'E748: No previously used register' , eval ( 'msg' ): gsub ( '\n' , '' )) 1631end ) 1632 1633it ( 'single event for multi-expr :echo' , function () 1634command ( 'echo 1 2 | echon 1 2' ) 1635screen : expect ( { 1636grid =[[ 1637^ | 1638{1:~ }|*4 1639]] , 1640messages ={ 1641{ content ={ { '1 2' } } , kind ='echo' } , 1642{ content ={ { '12' } } , kind ='echo' , append =true } , 1643} , 1644} ) 1645end ) 1646 1647it ( 'completion message overwrites previous' , function () 1648command ( 'set shortmess-=C | edit foo | edit bar | edit baz' ) 1649feed ( 'i<C-N>' ) 1650screen : expect ( { 1651grid =[[ 1652^ | 1653{1:~ }|*4 1654]] , 1655messages ={ 1656{ 1657content ={ { 'Scanning tags.' , 6 , 'Question' } } , 1658kind ='progress' , 1659id ='nvim.completion' , 1660} , 1661} , 1662showmode ={ 1663{ '-- Keyword completion (^N^P) ' , 5 , 'ModeMsg' } , 1664{ 'Pattern not found' , 9 , 'ErrorMsg' } , 1665} , 1666} ) 1667end ) 1668 1669it ( 'trigger' , function () 1670command ( 'echo "foo"' ) 1671screen : expect ( { 1672grid =[[ 1673^ | 1674{1:~ }|*4 1675]] , 1676messages ={ { content ={ { 'foo' } } , kind ='echo' , trigger ='' } } , 1677} ) 1678command ( 'map Q :echo "foo"<CR>' ) 1679feed ( 'Q' ) 1680screen : expect ( { 1681grid =[[ 1682^ | 1683{1:~ }|*4 1684]] , 1685messages ={ { content ={ { 'foo' } } , kind ='echo' , trigger ='' } } , 1686} ) 1687feed ( ':echo "foo"<CR>' ) 1688screen : expect ( { 1689grid =[[ 1690^ | 1691{1:~ }|*4 1692]] , 1693messages ={ { content ={ { 'foo' } } , kind ='echo' , trigger ='typed_cmd' } } , 1694} ) 1695end ) 1696end ) 1697 1698describe ( 'ui/builtin messages' , function () 1699local screen 1700before_each ( function () 1701clear () 1702screen =Screen . new ( 60 , 7 , { rgb =true , ext_popupmenu =true } ) 1703screen : add_extra_attr_ids { 1704[ 100 ] ={ background =Screen . colors . LightRed } , 1705[ 101 ] ={ background =Screen . colors . Grey20 } , 1706[ 102 ] ={ foreground =Screen . colors . Magenta1 , bold =true } , 1707} 1708end ) 1709 1710it ( 'supports multiline messages from rpc' , function () 1711feed ( ':call rpcrequest(1, "test_method")<cr>' ) 1712 1713screen : expect { 1714grid =[[ 1715{3: }| 1716{9:Invoking 'test_method' on channel 1:} | 1717{9:complete} | 1718{9:error} | 1719| 1720{9:message} | 1721{6:Press ENTER or type command to continue}^ | 1722]] , 1723request_cb =function ( name ) 1724if name == 'test_method' then 1725set_method_error ( 'complete\nerror\n\nmessage' ) 1726end 1727end , 1728} 1729end ) 1730 1731it ( 'no cursor flicker during :write message (marks UI busy) #25974' , function () 1732local fname ='Xtest_write_busy' 1733finally ( function () 1734os . remove ( fname ) 1735end ) 1736local busy_start , busy_stop =0 , 0 1737screen . _handle_busy_start =( function ( orig ) 1738return function () 1739orig ( screen ) 1740busy_start =busy_start + 1 1741end 1742end )( screen . _handle_busy_start ) 1743screen . _handle_busy_stop =( function ( orig ) 1744return function () 1745orig ( screen ) 1746busy_stop =busy_stop + 1 1747end 1748end )( screen . _handle_busy_stop ) 1749command ( 'write ' .. fname ) 1750screen : expect ( { any ='written' } ) 1751eq ( true , busy_start >= 1 ) -- cursor was hidden while the message was emitted 1752eq ( busy_start , busy_stop ) -- balanced: cursor restored afterwards 1753end ) 1754 1755it ( ':write message not clobbered by v:lua in statusline redraw #40616' , function () 1756local fname ='Xtest_write_progress' 1757finally ( function () 1758os . remove ( fname ) 1759end ) 1760exec_lua ( function () 1761-- The Progress event fired by the ":write" message (since ff68fd6b8a84) 1762-- evaluates statusline mid-message. 1763_G . Statusline =function () 1764return 'STL' 1765end 1766vim . o . laststatus =2 1767vim . o . statusline ='%{v:lua.Statusline()}' 1768vim . api . nvim_create_autocmd ( 'Progress' , { 1769callback =function () 1770vim . cmd ( 'redrawstatus!' ) 1771end , 1772} ) 1773end ) 1774command ( 'write ' .. fname ) 1775-- Should not be overwritten by "return Statusline(...)"). 1776screen : expect ( { any =( '"%s".*written' ): format ( fname ) } ) 1777end ) 1778 1779it ( ':hi Group output' , function () 1780screen : try_resize ( 70 , 7 ) 1781feed ( ':hi ErrorMsg<cr>' ) 1782screen : expect ( [[ 1783| 1784{1:~ }|*2 1785{3: }| 1786:hi ErrorMsg | 1787ErrorMsg {9:xxx} {18:ctermfg=}15 {18:ctermbg=}1 {18:guifg=}White {18:guibg=}Red | 1788{6:Press ENTER or type command to continue}^ | 1789]] ) 1790 1791feed ( '<cr>' ) 1792screen : try_resize ( 30 , 7 ) 1793feed ( ':hi ErrorMsg<cr>' ) 1794screen : expect ( [[ 1795:hi ErrorMsg | 1796ErrorMsg {9:xxx} {18:ctermfg=}15 | 1797{18:ctermbg=}1 | 1798{18:guifg=}White| 1799{18:guibg=}Red | 1800{6:Press ENTER or type command to}| 1801{6: continue}^ | 1802]] ) 1803feed ( '<cr>' ) 1804 1805-- screen size doesn't affect internal output #10285 1806eq ( 'ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red' , exec_capture ( 'hi ErrorMsg' )) 1807end ) 1808 1809it ( ':syntax list langGroup output' , function () 1810command ( 'syntax on' ) 1811exec ( [[ 1812syn match vimComment excludenl +\s"[^\-:.%#=*].*$+lc=1 contains=@vimCommentGroup,vimCommentString 1813syn match vimComment +\<endif\s\+".*$+lc=5 contains=@vimCommentGroup,vimCommentString 1814syn match vimComment +\<else\s\+".*$+lc=4 contains=@vimCommentGroup,vimCommentString 1815hi link vimComment Comment 1816]] ) 1817screen : try_resize ( 110 , 7 ) 1818feed ( ':syntax list vimComment<cr>' ) 1819screen : expect ( [[ 1820{102:--- Syntax items ---} | 1821vimComment {18:xxx} {18:match} /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 {18:excludenl} {18:contains}=@vimCommentGroup,vimCommentString | 1822| 1823{18:match} /\<endif\s\+".*$/ms=s+5,lc=5 {18:contains}=@vimCommentGroup,vimCommentString | 1824{18:match} /\<else\s\+".*$/ms=s+4,lc=4 {18:contains}=@vimCommentGroup,vimCommentString | 1825{18:links to} Comment | 1826{6:Press ENTER or type command to continue}^ | 1827]] ) 1828 1829feed ( '<cr>' ) 1830screen : try_resize ( 55 , 7 ) 1831feed ( ':syntax list vimComment<cr>' ) 1832screen : expect ( [[ 1833| 1834{18:match} /\<endif\s\+".*$/ms=s+5,lc=5 | 1835{18:contains}=@vimCommentGroup,vimCommentString | 1836{18:match} /\<else\s\+".*$/ms=s+4,lc=4 {18:c}| 1837{18:ontains}=@vimCommentGroup,vimCommentString | 1838{18:links to} Comment | 1839{6:Press ENTER or type command to continue}^ | 1840]] ) 1841feed ( '<cr>' ) 1842 1843-- ignore final whitespace inside string 1844-- luacheck: push ignore 1845eq ( 1846t . dedent [[ 1847--- Syntax items --- 1848vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vimCommentGroup,vimCommentString 1849match /\<endif\s\+".*$/ms=s+5,lc=5 contains=@vimCommentGroup,vimCommentString 1850match /\<else\s\+".*$/ms=s+4,lc=4 contains=@vimCommentGroup,vimCommentString 1851links to Comment]] , 1852exec_capture ( 'syntax list vimComment' ) 1853) 1854-- luacheck: pop 1855end ) 1856 1857it ( 'no empty line after :silent #12099' , function () 1858exec ( [[ 1859func T1() 1860silent !echo 1861echo "message T1" 1862endfunc 1863func T2() 1864silent lua print("lua message") 1865echo "message T2" 1866endfunc 1867func T3() 1868silent call nvim_out_write("api message\n") 1869echo "message T3" 1870endfunc 1871]] ) 1872feed ( ':call T1()<CR>' ) 1873screen : expect ( [[ 1874^ | 1875{1:~ }|*5 1876message T1 | 1877]] ) 1878feed ( ':call T2()<CR>' ) 1879screen : expect ( [[ 1880^ | 1881{1:~ }|*5 1882message T2 | 1883]] ) 1884feed ( ':call T3()<CR>' ) 1885screen : expect ( [[ 1886^ | 1887{1:~ }|*5 1888message T3 | 1889]] ) 1890end ) 1891 1892it ( 'supports ruler with laststatus=0' , function () 1893command ( 'set laststatus=0 ruler rulerformat=%-15(%c%V\\ %p%%%)' ) 1894screen : expect ( [[ 1895^ | 1896{1:~ }|*5 18970-1 100% | 1898]] ) 1899 1900-- Ruler is cleared when it is no longer drawn. 1901command ( 'set noruler' ) 1902screen : expect ( [[ 1903^ | 1904{1:~ }|*5 1905| 1906]] ) 1907 1908command ( 'set ruler rulerformat&' ) 1909screen : expect ( [[ 1910^ | 1911{1:~ }|*5 19120,0-1 All| 1913]] ) 1914 1915command ( 'hi MsgArea guibg=#333333' ) 1916screen : expect ( [[ 1917^ | 1918{1:~ }|*5 1919{101: 0,0-1 All}| 1920]] ) 1921end ) 1922 1923it ( 'supports echo with CRLF line separators' , function () 1924feed ( ':echo "line 1\\r\\nline 2"<cr>' ) 1925screen : expect ( [[ 1926| 1927{1:~ }|*2 1928{3: }| 1929line 1 | 1930line 2 | 1931{6:Press ENTER or type command to continue}^ | 1932]] ) 1933 1934feed ( '<cr>:echo "abc\\rz"<cr>' ) 1935screen : expect ( [[ 1936^ | 1937{1:~ }|*5 1938zbc | 1939]] ) 1940end ) 1941 1942it ( 'redraws UPD_NOT_VALID correctly after message' , function () 1943-- edge case: only one window was set UPD_NOT_VALID. Original report 1944-- used :make, but fake it using one command to set the current 1945-- window UPD_NOT_VALID and another to show a long message. 1946command ( 'set more' ) 1947feed ( ':new<cr><c-w><c-w>' ) 1948screen : expect ( [[ 1949| 1950{1:~ }| 1951{2:[No Name] }| 1952^ | 1953{1:~ }| 1954{3:[No Name] }| 1955:new | 1956]] ) 1957 1958feed ( ':set colorcolumn=10 | digraphs<cr>' ) 1959screen : expect ( [[ 1960:set colorcolumn=10 | digraphs | 1961NU {18:^@} 10 SH {18:^A} 1 SX {18:^B} 2 EX {18:^C} 3 | 1962ET {18:^D} 4 EQ {18:^E} 5 AK {18:^F} 6 BL {18:^G} 7 | 1963BS {18:^H} 8 HT {18:^I} 9 LF {18:^@} 10 VT {18:^K} 11 | 1964FF {18:^L} 12 CR {18:^M} 13 SO {18:^N} 14 SI {18:^O} 15 | 1965DL {18:^P} 16 D1 {18:^Q} 17 D2 {18:^R} 18 D3 {18:^S} 19 | 1966{6:-- More --}^ | 1967]] ) 1968 1969feed ( 'q' ) 1970screen : expect ( [[ 1971| 1972{1:~ }| 1973{2:[No Name] }| 1974^ {100: } | 1975{1:~ }| 1976{3:[No Name] }| 1977| 1978]] ) 1979 1980-- edge case: just covers statusline 1981feed ( ':set colorcolumn=5 | lua error("x\\n\\nx")<cr>' ) 1982screen : expect ( [[ 1983{9:E5108: Lua: [string ":lua"]:1: x} | 1984| 1985{9:x} | 1986{9:stack traceback:} | 1987{9: [C]: in function 'error'} | 1988{9: [string ":lua"]:1: in main chunk} | 1989{6:Press ENTER or type command to continue}^ | 1990]] ) 1991 1992feed ( '<cr>' ) 1993screen : expect ( [[ 1994| 1995{1:~ }| 1996{2:[No Name] }| 1997^ {100: } | 1998{1:~ }| 1999{3:[No Name] }| 2000| 2001]] ) 2002 2003-- edge case: just covers lowest window line 2004feed ( ':set colorcolumn=5 | lua error("x\\n\\n\\nx")<cr>' ) 2005screen : expect ( [[ 2006{9:E5108: Lua: [string ":lua"]:1: x} | 2007|*2 2008{9:x} | 2009{9:stack traceback:} | 2010{9: [C]: in function 'error'} | 2011{6:-- More --}^ | 2012]] ) 2013 2014feed ( '<cr>' ) 2015screen : expect ( [[ 2016|*2 2017{9:x} | 2018{9:stack traceback:} | 2019{9: [C]: in function 'error'} | 2020{9: [string ":lua"]:1: in main chunk} | 2021{6:Press ENTER or type command to continue}^ | 2022]] ) 2023end ) 2024 2025it ( 'supports nvim_echo messages with multiple attrs' , function () 2026local chunks ={ { 'wow, ' , 'Search' } , { 'such\n\nvery ' , 'ErrorMsg' } , { 'color' , 'LineNr' } } 2027async_meths . nvim_echo ( chunks , true , {} ) 2028screen : expect ( [[ 2029| 2030{1:~ }| 2031{3: }| 2032{10:wow, }{9:such} | 2033| 2034{9:very }{8:color} | 2035{6:Press ENTER or type command to continue}^ | 2036]] ) 2037 2038feed '<cr>' 2039screen : expect ( [[ 2040^ | 2041{1:~ }|*5 2042| 2043]] ) 2044 2045feed ':messages<cr>' 2046screen : expect ( [[ 2047| 2048{1:~ }| 2049{3: }| 2050{10:wow, }{9:such} | 2051| 2052{9:very }{8:color} | 2053{6:Press ENTER or type command to continue}^ | 2054]] ) 2055end ) 2056 2057it ( 'supports nvim_echo messages with emoji' , function () 2058-- stylua: ignore 2059async_meths . nvim_echo ( { { 'wow, 🏳️⚧️🧑🌾❤️😂🏴☠️\nvariant ❤️ one\nvariant ❤ two' } } , true , {} ) 2060 2061screen : expect ( [[ 2062| 2063{1:~ }| 2064{3: }| 2065wow, 🏳️⚧️🧑🌾❤️😂🏴☠️ | 2066variant ❤️ one | 2067variant ❤ two | 2068{6:Press ENTER or type command to continue}^ | 2069]] ) 2070 2071feed '<cr>' 2072screen : expect ( [[ 2073^ | 2074{1:~ }|*5 2075| 2076]] ) 2077 2078feed ':messages<cr>' 2079screen : expect ( [[ 2080| 2081{1:~ }| 2082{3: }| 2083wow, 🏳️⚧️🧑🌾❤️😂🏴☠️ | 2084variant ❤️ one | 2085variant ❤ two | 2086{6:Press ENTER or type command to continue}^ | 2087]] ) 2088end ) 2089 2090it ( 'prints lines in Ex mode correctly with a burst of carriage returns #19341' , function () 2091command ( 'set number' ) 2092api . nvim_buf_set_lines ( 0 , 0 , 0 , true , { 'aaa' , 'bbb' , 'ccc' } ) 2093-- Empty lines advance the cursor and print; a bare address moves and prints. 2094feed ( 'gg1q:<CR><CR>1<CR><CR>' ) 2095screen : expect ( { any =vim . pesc ( '" bbb' ) } ) 2096feed ( 'vi<CR>' ) 2097screen : expect ( [[ 2098{8: 2 }^bbb | 2099{8: 3 }ccc | 2100{8: 4 } | 2101{1:~ }|*3 2102| 2103]] ) 2104end ) 2105 2106describe ( 'echo messages are shown when immediately followed by' , function () 2107--- @param to_block string command to cause a blocking wait 2108--- @param to_unblock number|string number: timeout for blocking screen 2109--- string: keys to stop the blocking wait 2110local function test_flush_before_block ( to_block , to_unblock ) 2111local timeout =type ( to_unblock ) == 'number' and to_unblock or nil 2112exec (( [[ 2113func PrintAndWait() 2114echon "aaa\nbbb" 2115%s 2116echon "\nccc" 2117endfunc 2118]] ): format ( to_block )) 2119feed ( ':call PrintAndWait()' ) 2120screen : expect ( [[ 2121| 2122{1:~ }|*5 2123:call PrintAndWait()^ | 2124]] ) 2125feed ( '<CR>' ) 2126screen : expect { 2127grid =[[ 2128| 2129{1:~ }|*3 2130{3: }| 2131aaa | 2132bbb^ | 2133]] , 2134timeout =timeout , 2135} 2136if type ( to_unblock ) == 'string' then 2137feed ( to_unblock ) 2138end 2139screen : expect ( [[ 2140| 2141{1:~ }| 2142{3: }| 2143aaa | 2144bbb | 2145ccc | 2146{6:Press ENTER or type command to continue}^ | 2147]] ) 2148end 2149 2150it ( 'getchar()' , function () 2151test_flush_before_block ( [[call getchar()]] , 'k' ) 2152end ) 2153 2154it ( 'wait()' , function () 2155test_flush_before_block ( [[call wait(300, '0')]] , 100 ) 2156end ) 2157 2158it ( 'lua vim.wait()' , function () 2159test_flush_before_block ( [[lua vim.wait(300, function() end)]] , 100 ) 2160end ) 2161end ) 2162 2163it ( 'consecutive calls to win_move_statusline() work after multiline message #21014' , function () 2164async_meths . nvim_exec ( 2165[[ 2166echo "\n" 2167call win_move_statusline(0, -4) 2168call win_move_statusline(0, 4) 2169]] , 2170false 2171) 2172screen : expect ( [[ 2173| 2174{1:~ }|*3 2175{3: }| 2176| 2177{6:Press ENTER or type command to continue}^ | 2178]] ) 2179feed ( '<CR>' ) 2180screen : expect ( [[ 2181^ | 2182{1:~ }|*5 2183| 2184]] ) 2185eq ( 1 , api . nvim_get_option_value ( 'cmdheight' , {} )) 2186end ) 2187 2188it ( 'using nvim_echo in VimResized does not cause hit-enter prompt #26139' , function () 2189command ( [[au VimResized * lua vim.api.nvim_echo({ { '123456' } }, true, {})]] ) 2190screen : try_resize ( 60 , 5 ) 2191screen : expect ( [[ 2192^ | 2193{1:~ }|*3 2194| 2195]] ) 2196eq ( { mode ='n' , blocking =false } , api . nvim_get_mode ()) 2197end ) 2198 2199it ( 'bottom of screen is cleared after increasing &cmdheight #20360' , function () 2200command ( 'set laststatus=2' ) 2201screen : expect ( [[ 2202^ | 2203{1:~ }|*4 2204{3:[No Name] }| 2205| 2206]] ) 2207command ( 'set cmdheight=4' ) 2208screen : expect ( [[ 2209^ | 2210{1:~ }| 2211{3:[No Name] }| 2212|*4 2213]] ) 2214end ) 2215 2216it ( 'supports :intro with cmdheight=0 #26505' , function () 2217screen : try_resize ( 80 , 24 ) 2218command ( 'set cmdheight=0' ) 2219feed ( ':intro<CR>' ) 2220screen : expect ( [[ 2221|*3 2222{16:│} {26:╲} {26:││} | 2223{16:││}{26:╲╲││} | 2224{16:││} {26:╲} {26:│} | 2225| 2226{MATCH:.*}| 2227{1:────────────────────────────────────────────} | 2228Nvim is open source and freely distributable | 2229https://neovim.io/#chat | 2230{1:────────────────────────────────────────────} | 2231type {18::}{25:help nvim}{18:<Enter>} if you are new! | 2232type {18::}{25:checkhealth}{18:<Enter>} to optimize Nvim | 2233type {18::}{25:q}{18:<Enter>} to exit | 2234type {18::}{25:help}{18:<Enter>} for help | 2235{1:────────────────────────────────────────────} | 2236type {18::}{25:help news}{18:<Enter>} for v{MATCH:%d+%.%d+} notes{MATCH: *}| 2237{1:────────────────────────────────────────────} | 2238Help poor children in Uganda! | 2239type {18::}{25:help Kuwasha}{18:<Enter>} for information | 2240|*2 2241^ | 2242]] ) 2243feed ( '<CR>' ) 2244assert_alive () 2245end ) 2246 2247it ( ':intro with small screen #38396' , function () 2248screen : try_resize ( 80 , 6 ) 2249feed ( ':intro<CR>' ) 2250screen : expect ( { any ='NVIM' } ) 2251feed ( '<CR>' ) 2252assert_alive () 2253end ) 2254 2255it ( 'no wait return before delayed exception error message' , function () 2256screen : try_resize ( 70 , 7 ) 2257feed ( 'ia<esc>:lua vim.cmd.quit()<CR>' ) 2258screen : expect ( { 2259any ={ 2260'{9:.*Vim:E37: No write since.*}' , 2261'{6:Press ENTER or type command to continue}^' , 2262} , 2263} ) 2264end ) 2265end ) 2266 2267it ( 'calling screenstring() after redrawing between messages without UI #20999' , function () 2268clear () 2269exec ( [[ 2270echo repeat('a', 100) 2271redraw 2272echo "\n" 2273call screenstring(1, 1) 2274]] ) 2275assert_alive () 2276end ) 2277 2278describe ( 'ui/ext_messages' , function () 2279local screen 2280 2281before_each ( function () 2282clear { args_rm ={ '--headless' } , args ={ '--cmd' , 'set shortmess-=I' } } 2283screen =Screen . new ( 80 , 24 , { rgb =true , ext_messages =true , ext_popupmenu =true } ) 2284end ) 2285 2286it ( 'supports intro screen' , function () 2287-- intro message is not externalized. But check that it still works. 2288-- Note parts of it depends on version or is indeterministic. We ignore those parts. 2289local introscreen =[[ 2290^ | 2291{1:~ }|*2 2292{1:~ }{16:│} {26:╲} {26:││}{1: }| 2293{1:~ }{16:││}{26:╲╲││}{1: }| 2294{1:~ }{16:││} {26:╲} {26:│}{1: }| 2295{1:~ }| 2296{1:~{MATCH: +}}{26:NVIM {MATCH:%S+}}{1:{MATCH: +}}| 2297{1:~ ──────────────────────────────────────────── }| 2298{1:~ }Nvim is open source and freely distributable{1: }| 2299{1:~ }https://neovim.io/#chat{1: }| 2300{1:~ ──────────────────────────────────────────── }| 2301{1:~ }type {18::}{25:help nvim}{18:<Enter>} if you are new! {1: }| 2302{1:~ }type {18::}{25:checkhealth}{18:<Enter>} to optimize Nvim{1: }| 2303{1:~ }type {18::}{25:q}{18:<Enter>} to exit {1: }| 2304{1:~ }type {18::}{25:help}{18:<Enter>} for help {1: }| 2305{1:~ ──────────────────────────────────────────── }| 2306{1:~ }type {18::}{25:help news}{18:<Enter>} for v{MATCH:%d+%.%d+} notes {1:{MATCH: +}}| 2307{1:~ ──────────────────────────────────────────── }| 2308{1:~ }Help poor children in Uganda!{1: }| 2309{1:~ }type {18::}{25:help Kuwasha}{18:<Enter>} for information {1: }| 2310{1:~ }|*3 2311]] 2312local showmode ={ { '-- INSERT --' , 5 , 'ModeMsg' } } 2313screen : expect ( introscreen ) 2314 2315-- <c-l> (same as :mode) does _not_ clear intro message 2316feed ( '<c-l>i' ) 2317screen : expect { grid =introscreen , showmode =showmode } 2318 2319-- opening a float without focus also does not 2320local win =api . nvim_open_win ( api . nvim_create_buf ( false , false ), false , { 2321relative ='editor' , 2322height =1 , 2323width =5 , 2324row =1 , 2325col =5 , 2326} ) 2327screen : expect { 2328grid =[[ 2329^ | 2330{1:~ }{4: }{1: }| 2331{1:~ }| 2332{1:~ }{16:│} {26:╲} {26:││}{1: }| 2333{1:~ }{16:││}{26:╲╲││}{1: }| 2334{1:~ }{16:││} {26:╲} {26:│}{1: }| 2335{1:~ }| 2336{1:~{MATCH: +}}{26:NVIM {MATCH:%S+}}{1:{MATCH: +}}| 2337{1:~ ──────────────────────────────────────────── }| 2338{1:~ }Nvim is open source and freely distributable{1: }| 2339{1:~ }https://neovim.io/#chat{1: }| 2340{1:~ ──────────────────────────────────────────── }| 2341{1:~ }type {18::}{25:help nvim}{18:<Enter>} if you are new! {1: }| 2342{1:~ }type {18::}{25:checkhealth}{18:<Enter>} to optimize Nvim{1: }| 2343{1:~ }type {18::}{25:q}{18:<Enter>} to exit {1: }| 2344{1:~ }type {18::}{25:help}{18:<Enter>} for help {1: }| 2345{1:~ ──────────────────────────────────────────── }| 2346{1:~ }type {18::}{25:help news}{18:<Enter>} for v{MATCH:%d+%.%d+} notes {1:{MATCH: +}}| 2347{1:~ ──────────────────────────────────────────── }| 2348{1:~ }Help poor children in Uganda!{1: }| 2349{1:~ }type {18::}{25:help Kuwasha}{18:<Enter>} for information {1: }| 2350{1:~ }|*3 2351]] , 2352showmode =showmode , 2353} 2354 2355api . nvim_win_close ( win , true ) 2356screen : expect { grid =introscreen , showmode =showmode } 2357 2358-- but editing text does.. 2359feed ( 'x' ) 2360screen : expect { 2361grid =[[ 2362x^ | 2363{1:~ }|*23 2364]] , 2365showmode =showmode , 2366} 2367 2368feed ( '<esc>:intro<cr>' ) 2369screen : expect { 2370grid =[[ 2371^ | 2372|*2 2373{16:│} {26:╲} {26:││} | 2374{16:││}{26:╲╲││} | 2375{16:││} {26:╲} {26:│} | 2376| 2377{MATCH: +}{26:NVIM {MATCH:%S+}}{MATCH: +}| 2378{1:────────────────────────────────────────────} | 2379Nvim is open source and freely distributable | 2380https://neovim.io/#chat | 2381{1:────────────────────────────────────────────} | 2382type {18::}{25:help nvim}{18:<Enter>} if you are new! | 2383type {18::}{25:checkhealth}{18:<Enter>} to optimize Nvim | 2384type {18::}{25:q}{18:<Enter>} to exit | 2385type {18::}{25:help}{18:<Enter>} for help | 2386{1:────────────────────────────────────────────} | 2387type {18::}{25:help news}{18:<Enter>} for v{MATCH:%d+%.%d+} notes {MATCH: +}| 2388{1:────────────────────────────────────────────} | 2389Help poor children in Uganda! | 2390type {18::}{25:help Kuwasha}{18:<Enter>} for information | 2391|*3 2392]] , 2393} 2394 2395feed ( '<cr>' ) 2396screen : expect ( [[ 2397^x | 2398{1:~ }|*23 2399]] ) 2400end ) 2401 2402it ( 'clears intro screen when new buffer is active' , function () 2403api . nvim_set_current_buf ( api . nvim_create_buf ( true , false )) 2404screen : expect ( [[ 2405^ | 2406{1:~ }|*23 2407]] ) 2408end ) 2409 2410it ( 'clears intro screen when new buffer is active in floating window' , function () 2411local win_opts ={ relative ='editor' , height =1 , width =5 , row =1 , col =5 } 2412api . nvim_open_win ( api . nvim_create_buf ( false , false ), true , win_opts ) 2413screen : expect ( [[ 2414| 2415{1:~ }{4:^ }{1: }| 2416{1:~ }|*22 2417]] ) 2418end ) 2419 2420it ( 'clears intro screen when initial buffer is active in floating window' , function () 2421local win_opts ={ relative ='editor' , height =1 , width =5 , row =1 , col =5 } 2422api . nvim_open_win ( api . nvim_get_current_buf (), true , win_opts ) 2423screen : expect ( [[ 2424| 2425{1:~ }{4:^ }{1: }| 2426{1:~ }|*22 2427]] ) 2428end ) 2429 2430it ( 'clears intro screen when initial window is converted to be floating' , function () 2431exec_lua ( [[ 2432local init_win_id = vim.api.nvim_get_current_win() 2433vim.cmd('split') 2434local win_opts = { relative = 'editor', height = 1, width = 5, row = 1, col = 5 } 2435vim.api.nvim_win_set_config(init_win_id, win_opts) 2436vim.api.nvim_set_current_win(init_win_id) 2437]] ) 2438screen : expect ( [[ 2439| 2440{1:~ }{4:^ }{1: }| 2441{1:~ }|*22 2442]] ) 2443end ) 2444 2445it ( 'supports global statusline' , function () 2446feed ( ':set laststatus=3<cr>' ) 2447feed ( ':sp<cr>' ) 2448feed ( ':set cmdheight<cr>' ) 2449screen : expect ( { 2450grid =[[ 2451^ | 2452{1:~ }|*10 2453────────────────────────────────────────────────────────────────────────────────| 2454| 2455{1:~ }|*10 2456{3:[No Name] }| 2457]] , 2458messages ={ { content ={ { ' cmdheight=0' } } , kind ='list_cmd' } } , 2459} ) 2460 2461feed ( '<c-w>+' ) 2462feed ( ':set laststatus<cr>' ) 2463screen : expect ( { 2464grid =[[ 2465^ | 2466{1:~ }|*11 2467────────────────────────────────────────────────────────────────────────────────| 2468| 2469{1:~ }|*9 2470{3:[No Name] }| 2471]] , 2472messages ={ { content ={ { ' laststatus=3' } } , kind ='list_cmd' } } , 2473} ) 2474 2475feed ( ':set mouse=a<cr>' ) 2476api . nvim_input_mouse ( 'left' , 'press' , '' , 0 , 12 , 10 ) 2477poke_eventloop () 2478api . nvim_input_mouse ( 'left' , 'drag' , '' , 0 , 11 , 10 ) 2479feed ( '<c-l>' ) 2480feed ( ':set cmdheight<cr>' ) 2481screen : expect ( { 2482grid =[[ 2483^ | 2484{1:~ }|*10 2485────────────────────────────────────────────────────────────────────────────────| 2486| 2487{1:~ }|*10 2488{3:[No Name] }| 2489]] , 2490messages ={ { content ={ { ' cmdheight=0' } } , kind ='list_cmd' } } , 2491} ) 2492end ) 2493end ) 2494 2495it ( 'ui/ext_multigrid supports intro screen' , function () 2496clear { args_rm ={ '--headless' } , args ={ '--cmd' , 'set shortmess-=I' } } 2497local screen =Screen . new ( 80 , 24 , { rgb =true , ext_multigrid =true } ) 2498 2499screen : expect { 2500grid =[[ 2501## grid 1 2502[2:--------------------------------------------------------------------------------]|*23 2503[3:--------------------------------------------------------------------------------]| 2504## grid 2 2505^ | 2506{1:~ }|*2 2507{1:~ }{16:│} {26:╲} {26:││}{1: }| 2508{1:~ }{16:││}{26:╲╲││}{1: }| 2509{1:~ }{16:││} {26:╲} {26:│}{1: }| 2510{1:~ }| 2511{1:~{MATCH: +}}{26:NVIM {MATCH:%S+}}{1:{MATCH: +}}| 2512{1:~ ──────────────────────────────────────────── }| 2513{1:~ }Nvim is open source and freely distributable{1: }| 2514{1:~ }https://neovim.io/#chat{1: }| 2515{1:~ ──────────────────────────────────────────── }| 2516{1:~ }type {18::}{25:help nvim}{18:<Enter>} if you are new! {1: }| 2517{1:~ }type {18::}{25:checkhealth}{18:<Enter>} to optimize Nvim{1: }| 2518{1:~ }type {18::}{25:q}{18:<Enter>} to exit {1: }| 2519{1:~ }type {18::}{25:help}{18:<Enter>} for help {1: }| 2520{1:~ ──────────────────────────────────────────── }| 2521{1:~ }type {18::}{25:help news}{18:<Enter>} for v{MATCH:%d+%.%d+} notes {1:{MATCH: +}}| 2522{1:~ ──────────────────────────────────────────── }| 2523{1:~ }Help poor children in Uganda!{1: }| 2524{1:~ }type {18::}{25:help Kuwasha}{18:<Enter>} for information {1: }| 2525{1:~ }|*2 2526## grid 3 2527| 2528]] , 2529win_viewport ={ 2530[ 2 ] ={ 2531win =1000 , 2532topline =0 , 2533botline =2 , 2534curline =0 , 2535curcol =0 , 2536linecount =1 , 2537sum_scroll_delta =0 , 2538} , 2539} , 2540} 2541 2542feed 'ix' 2543screen : expect { 2544grid =[[ 2545## grid 1 2546[2:--------------------------------------------------------------------------------]|*23 2547[3:--------------------------------------------------------------------------------]| 2548## grid 2 2549x^ | 2550{1:~ }|*22 2551## grid 3 2552{5:-- INSERT --} | 2553]] , 2554win_viewport ={ 2555[ 2 ] ={ 2556win =1000 , 2557topline =0 , 2558botline =2 , 2559curline =0 , 2560curcol =1 , 2561linecount =1 , 2562sum_scroll_delta =0 , 2563} , 2564} , 2565} 2566end ) 2567 2568describe ( 'ui/msg_puts_printf' , function () 2569it ( 'output multibyte characters correctly' , function () 2570skip ( not t . translations_enabled (), 'N/A: Nvim not built with ENABLE_TRANSLATIONS' ) 2571local screen 2572local cmd ='' 2573local build_dir =t . paths . test_build_dir 2574local locale_dir =build_dir .. '/share/locale/ja/LC_MESSAGES' 2575 2576clear ( { env ={ LANG ='ja_JP.UTF-8' } } ) 2577screen =Screen . new ( 25 , 5 ) 2578 2579if is_os ( 'win' ) then 2580if os . execute ( 'chcp 932 > NUL 2>&1' ) ~= 0 then 2581pending ( 'missing japanese language features' , function () end ) 2582return 2583else 2584cmd ='chcp 932 > NUL & ' 2585end 2586else 2587if not pcall ( n . command , 'lang ja_JP.UTF-8' ) then 2588pending ( 'Locale ja_JP.UTF-8 not supported' , function () end ) 2589return 2590end 2591end 2592 2593fn . mkdir ( locale_dir , 'p' ) 2594fn . filecopy ( build_dir .. '/src/nvim/po/ja.mo' , locale_dir .. '/nvim.mo' ) 2595-- "-Es" doesn't read stdin as commands, and the "Entering Ex mode" banner was removed, so 2596-- ":print" a translated message via "-S" (silent mode suppresses ":echo" output). #40966 2597t . write_file ( 2598'Xes_ja.vim' , 2599[[call setline(1, gettext("Entering Ex mode. Type \"visual\" to go to Normal mode."))]] 2600.. '\n' 2601.. '.print\n' 2602) 2603finally ( function () 2604os . remove ( 'Xes_ja.vim' ) 2605n . rmdir ( vim . fs . dirname ( locale_dir )) 2606end ) 2607 2608cmd =cmd .. '"' .. nvim_prog .. '" -u NONE -i NONE -Es -S Xes_ja.vim' 2609command ( [[call jobstart(']] .. cmd .. [[',{'term':v:true})]] ) 2610screen : expect ( [[ 2611^Exモードに入ります。ノー | 2612マルモードに戻るには "vis| 2613ual" と入力してください。| 2614[Process exited 0] | 2615| 2616]] ) 2617end ) 2618end ) 2619 2620describe ( 'pager' , function () 2621local screen 2622 2623before_each ( function () 2624clear () 2625screen =Screen . new ( 35 , 8 ) 2626screen : set_default_attr_ids ( { 2627[ 1 ] ={ bold =true , foreground =Screen . colors . Blue1 } , 2628[ 2 ] ={ foreground =Screen . colors . Grey100 , background =Screen . colors . Red } , 2629[ 3 ] ={ 2630foreground =Screen . colors . Grey100 , 2631background =Screen . colors . Red , 2632special =Screen . colors . Yellow , 2633} , 2634[ 4 ] ={ bold =true , foreground =Screen . colors . SeaGreen4 } , 2635[ 5 ] ={ special =Screen . colors . Yellow } , 2636[ 6 ] ={ special =Screen . colors . Yellow , bold =true , foreground =Screen . colors . SeaGreen4 } , 2637[ 7 ] ={ foreground =Screen . colors . Grey0 , background =Screen . colors . Grey100 } , 2638[ 8 ] ={ foreground =Screen . colors . Gray90 , background =Screen . colors . Grey100 } , 2639[ 9 ] ={ foreground =tonumber ( '0x00000c' ), background =Screen . colors . Grey100 } , 2640[ 10 ] ={ background =Screen . colors . Grey100 , bold =true , foreground =tonumber ( '0xe5e5ff' ) } , 2641[ 11 ] ={ background =Screen . colors . Grey100 , bold =true , foreground =tonumber ( '0x2b8452' ) } , 2642[ 12 ] ={ bold =true , reverse =true } , 2643[ 13 ] ={ foreground =Screen . colors . Grey0 } , 2644[ 14 ] ={ foreground =Screen . colors . Grey90 } , 2645[ 15 ] ={ foreground =tonumber ( '0x00000c' ) } , 2646[ 16 ] ={ bold =true , foreground =tonumber ( '0xe5e5ff' ) } , 2647[ 17 ] ={ bold =true , foreground =tonumber ( '0x2b8452' ) } , 2648} ) 2649command ( 'set more' ) 2650 2651exec_lua ( 2652'_G.x = ...' , 2653t . dedent [[ 2654Lorem ipsum dolor sit amet, consectetur 2655adipisicing elit, sed do eiusmod tempor 2656incididunt ut labore et dolore magna aliqua. 2657Ut enim ad minim veniam, quis nostrud xercitation 2658ullamco laboris nisi ut 2659aliquip ex ea commodo consequat. 2660]] 2661) 2662end ) 2663 2664it ( 'can be quit with echon' , function () 2665screen : try_resize ( 25 , 5 ) 2666feed ( ':echon join(map(range(0, &lines*10), "v:val"), "\\n")<cr>' ) 2667screen : expect ( [[ 26680 | 26691 | 26702 | 26713 | 2672{4:-- More --}^ | 2673]] ) 2674feed ( 'q' ) 2675screen : expect ( [[ 2676^ | 2677{1:~ }|*3 2678| 2679]] ) 2680end ) 2681 2682it ( 'can be quit with Lua #11224 #16537' , function () 2683screen : try_resize ( 40 , 5 ) 2684feed ( ':lua for i=0,10 do print(i) end<cr>' ) 2685screen : expect ( [[ 26860 | 26871 | 26882 | 26893 | 2690{4:-- More --}^ | 2691]] ) 2692feed ( 'q' ) 2693screen : expect ( [[ 2694^ | 2695{1:~ }|*3 2696| 2697]] ) 2698feed ( ':mess<cr>' ) 2699screen : expect ( [[ 27000 | 27011 | 27022 | 27033 | 2704{4:-- More --}^ | 2705]] ) 2706feed ( 'G' ) 2707screen : expect ( [[ 27087 | 27098 | 27109 | 271110 | 2712{4:Press ENTER or type command to continue}^ | 2713]] ) 2714feed ( '<cr>' ) 2715end ) 2716 2717it ( 'handles wrapped lines with line scroll' , function () 2718feed ( ':lua error(_G.x)<cr>' ) 2719screen : expect ( [[ 2720{2:E5108: Lua: [string ":lua"]:1: Lore}| 2721{2:m ipsum dolor sit amet, consectetur}| 2722| 2723{2:adipisicing elit, sed do eiusmod te}| 2724{2:mpor} | 2725{2:incididunt ut labore et dolore magn}| 2726{2:a aliqua.} | 2727{4:-- More --}^ | 2728]] ) 2729 2730feed ( 'j' ) 2731screen : expect ( [[ 2732{2:m ipsum dolor sit amet, consectetur}| 2733| 2734{2:adipisicing elit, sed do eiusmod te}| 2735{2:mpor} | 2736{2:incididunt ut labore et dolore magn}| 2737{2:a aliqua.} | 2738{2:Ut enim ad minim veniam, quis nostr}| 2739{4:-- More --}^ | 2740]] ) 2741 2742feed ( 'k' ) 2743screen : expect ( [[ 2744{2:E5108: Lua: [string ":lua"]:1: Lore}| 2745{2:m ipsum dolor sit amet, consectetur}| 2746| 2747{2:adipisicing elit, sed do eiusmod te}| 2748{2:mpor} | 2749{2:incididunt ut labore et dolore magn}| 2750{2:a aliqua.} | 2751{4:-- More --}^ | 2752]] ) 2753 2754feed ( 'j' ) 2755screen : expect ( [[ 2756{2:m ipsum dolor sit amet, consectetur}| 2757| 2758{2:adipisicing elit, sed do eiusmod te}| 2759{2:mpor} | 2760{2:incididunt ut labore et dolore magn}| 2761{2:a aliqua.} | 2762{2:Ut enim ad minim veniam, quis nostr}| 2763{4:-- More --}^ | 2764]] ) 2765end ) 2766 2767it ( 'handles wrapped lines with page scroll' , function () 2768feed ( ':lua error(_G.x)<cr>' ) 2769screen : expect ( [[ 2770{2:E5108: Lua: [string ":lua"]:1: Lore}| 2771{2:m ipsum dolor sit amet, consectetur}| 2772| 2773{2:adipisicing elit, sed do eiusmod te}| 2774{2:mpor} | 2775{2:incididunt ut labore et dolore magn}| 2776{2:a aliqua.} | 2777{4:-- More --}^ | 2778]] ) 2779feed ( 'd' ) 2780screen : expect ( [[ 2781{2:mpor} | 2782{2:incididunt ut labore et dolore magn}| 2783{2:a aliqua.} | 2784{2:Ut enim ad minim veniam, quis nostr}| 2785{2:ud xercitation} | 2786{2:ullamco laboris nisi ut} | 2787{2:aliquip ex ea commodo consequat.} | 2788{4:-- More --}^ | 2789]] ) 2790feed ( 'u' ) 2791screen : expect ( [[ 2792{2:E5108: Lua: [string ":lua"]:1: Lore}| 2793{2:m ipsum dolor sit amet, consectetur}| 2794| 2795{2:adipisicing elit, sed do eiusmod te}| 2796{2:mpor} | 2797{2:incididunt ut labore et dolore magn}| 2798{2:a aliqua.} | 2799{4:-- More --}^ | 2800]] ) 2801feed ( 'd' ) 2802screen : expect ( [[ 2803{2:mpor} | 2804{2:incididunt ut labore et dolore magn}| 2805{2:a aliqua.} | 2806{2:Ut enim ad minim veniam, quis nostr}| 2807{2:ud xercitation} | 2808{2:ullamco laboris nisi ut} | 2809{2:aliquip ex ea commodo consequat.} | 2810{4:-- More --}^ | 2811]] ) 2812end ) 2813 2814it ( 'handles wrapped lines with line scroll and MsgArea highlight' , function () 2815command ( 'hi MsgArea guisp=Yellow' ) 2816 2817feed ( ':lua error(_G.x)<cr>' ) 2818screen : expect ( [[ 2819{3:E5108: Lua: [string ":lua"]:1: Lore}| 2820{3:m ipsum dolor sit amet, consectetur}| 2821{5: }| 2822{3:adipisicing elit, sed do eiusmod te}| 2823{3:mpor}{5: }| 2824{3:incididunt ut labore et dolore magn}| 2825{3:a aliqua.}{5: }| 2826{6:-- More --}{5:^ }| 2827]] ) 2828 2829feed ( 'j' ) 2830screen : expect ( [[ 2831{3:m ipsum dolor sit amet, consectetur}| 2832{5: }| 2833{3:adipisicing elit, sed do eiusmod te}| 2834{3:mpor}{5: }| 2835{3:incididunt ut labore et dolore magn}| 2836{3:a aliqua.}{5: }| 2837{3:Ut enim ad minim veniam, quis nostr}| 2838{6:-- More --}{5:^ }| 2839]] ) 2840 2841feed ( 'k' ) 2842screen : expect ( [[ 2843{3:E5108: Lua: [string ":lua"]:1: Lore}| 2844{3:m ipsum dolor sit amet, consectetur}| 2845{5: }| 2846{3:adipisicing elit, sed do eiusmod te}| 2847{3:mpor}{5: }| 2848{3:incididunt ut labore et dolore magn}| 2849{3:a aliqua.}{5: }| 2850{6:-- More --}{5:^ }| 2851]] ) 2852 2853feed ( 'j' ) 2854screen : expect ( [[ 2855{3:m ipsum dolor sit amet, consectetur}| 2856{5: }| 2857{3:adipisicing elit, sed do eiusmod te}| 2858{3:mpor}{5: }| 2859{3:incididunt ut labore et dolore magn}| 2860{3:a aliqua.}{5: }| 2861{3:Ut enim ad minim veniam, quis nostr}| 2862{6:-- More --}{5:^ }| 2863]] ) 2864end ) 2865 2866it ( 'handles wrapped lines with page scroll and MsgArea highlight' , function () 2867command ( 'hi MsgArea guisp=Yellow' ) 2868feed ( ':lua error(_G.x)<cr>' ) 2869screen : expect ( [[ 2870{3:E5108: Lua: [string ":lua"]:1: Lore}| 2871{3:m ipsum dolor sit amet, consectetur}| 2872{5: }| 2873{3:adipisicing elit, sed do eiusmod te}| 2874{3:mpor}{5: }| 2875{3:incididunt ut labore et dolore magn}| 2876{3:a aliqua.}{5: }| 2877{6:-- More --}{5:^ }| 2878]] ) 2879feed ( 'd' ) 2880screen : expect ( [[ 2881{3:mpor}{5: }| 2882{3:incididunt ut labore et dolore magn}| 2883{3:a aliqua.}{5: }| 2884{3:Ut enim ad minim veniam, quis nostr}| 2885{3:ud xercitation}{5: }| 2886{3:ullamco laboris nisi ut}{5: }| 2887{3:aliquip ex ea commodo consequat.}{5: }| 2888{6:-- More --}{5:^ }| 2889]] ) 2890feed ( 'u' ) 2891screen : expect ( [[ 2892{3:E5108: Lua: [string ":lua"]:1: Lore}| 2893{3:m ipsum dolor sit amet, consectetur}| 2894{5: }| 2895{3:adipisicing elit, sed do eiusmod te}| 2896{3:mpor}{5: }| 2897{3:incididunt ut labore et dolore magn}| 2898{3:a aliqua.}{5: }| 2899{6:-- More --}{5:^ }| 2900]] ) 2901feed ( 'd' ) 2902screen : expect ( [[ 2903{3:mpor}{5: }| 2904{3:incididunt ut labore et dolore magn}| 2905{3:a aliqua.}{5: }| 2906{3:Ut enim ad minim veniam, quis nostr}| 2907{3:ud xercitation}{5: }| 2908{3:ullamco laboris nisi ut}{5: }| 2909{3:aliquip ex ea commodo consequat.}{5: }| 2910{6:-- More --}{5:^ }| 2911]] ) 2912end ) 2913 2914it ( 'preserves MsgArea highlighting after more prompt' , function () 2915screen : try_resize ( 70 , 6 ) 2916command ( 'hi MsgArea guisp=Yellow' ) 2917command ( 'map x Lorem ipsum labore et dolore magna aliqua' ) 2918command ( 'map y adipisicing elit' ) 2919command ( 'map z incididunt ut' ) 2920command ( 'map a labore et dolore' ) 2921command ( 'map b ex ea commodo' ) 2922command ( 'map xx yy' ) 2923command ( 'map xy yz' ) 2924feed ( ':map<cr>' ) 2925screen : expect ( [[ 2926{5: a labore et dolore }| 2927{5: b ex ea commodo }| 2928{5: xy yz }| 2929{5: xx yy }| 2930{5: x Lorem ipsum labore et dolore magna aliqua }| 2931{6:-- More --}{5:^ }| 2932]] ) 2933feed ( 'j' ) 2934screen : expect ( [[ 2935{5: b ex ea commodo }| 2936{5: xy yz }| 2937{5: xx yy }| 2938{5: x Lorem ipsum labore et dolore magna aliqua }| 2939{5: y adipisicing elit }| 2940{6:-- More --}{5:^ }| 2941]] ) 2942feed ( 'j' ) 2943screen : expect ( [[ 2944{5: xy yz }| 2945{5: xx yy }| 2946{5: x Lorem ipsum labore et dolore magna aliqua }| 2947{5: y adipisicing elit }| 2948{5: z incididunt ut }| 2949{6:Press ENTER or type command to continue}{5:^ }| 2950]] ) 2951end ) 2952 2953it ( 'clears "-- more --" message' , function () 2954command ( 'hi MsgArea guisp=Yellow blend=10' ) 2955feed ( ':echon join(range(20), "\\n")<cr>' ) 2956screen : expect ( [[ 2957{13:0}{14: }| 2958{15:1}{16: }| 2959{15:2}{16: }| 2960{15:3}{16: }| 2961{15:4}{16: }| 2962{15:5}{16: }| 2963{15:6}{16: }| 2964{17:--}{14: }{17:More}{14: }{17:--}{14:^ }| 2965]] ) 2966 2967feed ( 'j' ) 2968screen : expect ( [[ 2969{13:1}{14: }| 2970{15:2}{16: }| 2971{15:3}{16: }| 2972{15:4}{16: }| 2973{15:5}{16: }| 2974{15:6}{16: }| 2975{15:7}{16: }| 2976{17:--}{14: }{17:More}{14: }{17:--}{14:^ }| 2977]] ) 2978 2979feed ( 'k' ) 2980screen : expect ( [[ 2981{13:0}{14: }| 2982{15:1}{16: }| 2983{15:2}{16: }| 2984{15:3}{16: }| 2985{15:4}{16: }| 2986{15:5}{16: }| 2987{15:6}{16: }| 2988{17:--}{14: }{17:More}{14: }{17:--}{14:^ }| 2989]] ) 2990 2991feed ( 'j' ) 2992screen : expect ( [[ 2993{13:1}{14: }| 2994{15:2}{16: }| 2995{15:3}{16: }| 2996{15:4}{16: }| 2997{15:5}{16: }| 2998{15:6}{16: }| 2999{15:7}{16: }| 3000{17:--}{14: }{17:More}{14: }{17:--}{14:^ }| 3001]] ) 3002end ) 3003 3004it ( 'with :!cmd does not crash on resize' , function () 3005skip ( fn . executable ( 'sleep' ) == 0 , 'missing "sleep" command' ) 3006feed ( ':!sleep 1<cr>' ) 3007screen : expect ( [[ 3008| 3009{1:~ }|*4 3010{12: }| 3011:!sleep 1 | 3012| 3013]] ) 3014 3015-- not processed while command is executing 3016async_meths . nvim_ui_try_resize ( 35 , 5 ) 3017 3018-- TODO(bfredl): ideally it should be processed just 3019-- before the "press ENTER" prompt though 3020screen : expect ( [[ 3021| 3022{1:~ }|*2 3023{12: }| 3024:!sleep 1 | 3025| 3026{4:Press ENTER or type command to cont}| 3027{4:inue}^ | 3028]] ) 3029 3030feed ( '<cr>' ) 3031screen : expect ( [[ 3032^ | 3033{1:~ }|*3 3034| 3035]] ) 3036end ) 3037 3038it ( 'can be resized' , function () 3039feed ( ':lua error(_G.x)<cr>' ) 3040screen : expect ( [[ 3041{2:E5108: Lua: [string ":lua"]:1: Lore}| 3042{2:m ipsum dolor sit amet, consectetur}| 3043| 3044{2:adipisicing elit, sed do eiusmod te}| 3045{2:mpor} | 3046{2:incididunt ut labore et dolore magn}| 3047{2:a aliqua.} | 3048{4:-- More --}^ | 3049]] ) 3050 3051-- responds to resize, but text is not reflown 3052screen : try_resize ( 45 , 5 ) 3053screen : expect ( [[ 3054{2:adipisicing elit, sed do eiusmod te} | 3055{2:mpor} | 3056{2:incididunt ut labore et dolore magn} | 3057{2:a aliqua.} | 3058{4:-- More --}^ | 3059]] ) 3060 3061-- can create empty space, as the command hasn't output the text below yet. 3062-- text is not reflown; existing lines get cut 3063screen : try_resize ( 30 , 12 ) 3064screen : expect ( [[ 3065:lua error(_G.x) | 3066{2:E5108: Lua: [string ":lua"]:1:}| 3067{2:m ipsum dolor sit amet, consec}| 3068{2:tetur} | 3069{2:adipisicing elit, sed do eiusm}| 3070{2:mpore} | 3071{2:incididunt ut labore et dolore}| 3072{2:a aliqua.} | 3073|*3 3074{4:-- More --}^ | 3075]] ) 3076 3077-- continues in a mostly consistent state, but only new lines are 3078-- wrapped at the new screen size. 3079feed ( '<cr>' ) 3080screen : expect ( [[ 3081{2:E5108: Lua: [string ":lua"]:1:}| 3082{2:m ipsum dolor sit amet, consec}| 3083{2:tetur} | 3084{2:adipisicing elit, sed do eiusm}| 3085{2:mpore} | 3086{2:incididunt ut labore et dolore}| 3087{2:a aliqua.} | 3088{2:Ut enim ad minim veniam, quis }| 3089{2:nostrud xercitation} | 3090{2:ullamco laboris nisi ut} | 3091{2:aliquip ex ea commodo consequa}| 3092{4:-- More --}^ | 3093]] ) 3094 3095feed ( '<cr>' ) 3096screen : expect ( [[ 3097{2:m ipsum dolor sit amet, consec}| 3098{2:tetur} | 3099{2:adipisicing elit, sed do eiusm}| 3100{2:mpore} | 3101{2:incididunt ut labore et dolore}| 3102{2:a aliqua.} | 3103{2:Ut enim ad minim veniam, quis }| 3104{2:nostrud xercitation} | 3105{2:ullamco laboris nisi ut} | 3106{2:aliquip ex ea commodo consequa}| 3107{2:t.} | 3108{4:-- More --}^ | 3109]] ) 3110 3111feed ( 'q' ) 3112screen : expect ( [[ 3113^ | 3114{1:~ }|*10 3115| 3116]] ) 3117end ) 3118 3119it ( 'with cmdheight=0 does not crash with g<' , function () 3120command ( 'set cmdheight=0' ) 3121feed ( ':ls<cr>' ) 3122screen : expect ( [[ 3123| 3124{1:~ }| 3125{12: }| 3126:ls | 31271 %a "[No Name]" | 3128line 1 | 3129{4:Press ENTER or type command to cont}| 3130{4:inue}^ | 3131]] ) 3132 3133feed ( '<cr>' ) 3134screen : expect ( [[ 3135^ | 3136{1:~ }|*7 3137]] ) 3138 3139feed ( 'g<lt>' ) 3140screen : expect ( [[ 3141| 3142{1:~ }| 3143{12: }| 3144:ls | 31451 %a "[No Name]" | 3146line 1 | 3147{4:Press ENTER or type command to cont}| 3148{4:inue}^ | 3149]] ) 3150 3151feed ( '<cr>' ) 3152screen : expect ( [[ 3153^ | 3154{1:~ }|*7 3155]] ) 3156end ) 3157 3158it ( 'g< shows blank line from :echo properly' , function () 3159screen : try_resize ( 60 , 8 ) 3160feed ( [[:echo 1 | echo "\n" | echo 2<CR>]] ) 3161screen : expect ( [[ 3162| 3163{1:~ }|*2 3164{12: }| 31651 | 3166| 31672 | 3168{4:Press ENTER or type command to continue}^ | 3169]] ) 3170 3171feed ( '<CR>' ) 3172screen : expect ( [[ 3173^ | 3174{1:~ }|*6 3175| 3176]] ) 3177 3178feed ( 'g<lt>' ) 3179screen : expect ( [[ 3180| 3181{1:~ }| 3182{12: }| 3183:echo 1 | echo "\n" | echo 2 | 31841 | 3185| 31862 | 3187{4:Press ENTER or type command to continue}^ | 3188]] ) 3189 3190feed ( '<CR>' ) 3191screen : expect ( [[ 3192^ | 3193{1:~ }|*6 3194| 3195]] ) 3196end ) 3197 3198it ( 'scrolling works properly when :echo output ends with newline' , function () 3199screen : try_resize ( 60 , 6 ) 3200feed ( [[:echo range(100)->join("\n") .. "\n"<CR>]] ) 3201screen : expect ( [[ 32020 | 32031 | 32042 | 32053 | 32064 | 3207{4:-- More --}^ | 3208]] ) 3209feed ( 'G' ) 3210screen : expect ( [[ 321196 | 321297 | 321398 | 321499 | 3215| 3216{4:Press ENTER or type command to continue}^ | 3217]] ) 3218for _ =1 , 3 do 3219feed ( 'k' ) 3220screen : expect ( [[ 322195 | 322296 | 322397 | 322498 | 322599 | 3226{4:-- More --}^ | 3227]] ) 3228feed ( 'k' ) 3229screen : expect ( [[ 323094 | 323195 | 323296 | 323397 | 323498 | 3235{4:-- More --}^ | 3236]] ) 3237feed ( 'j' ) 3238screen : expect ( [[ 323995 | 324096 | 324197 | 324298 | 324399 | 3244{4:-- More --}^ | 3245]] ) 3246feed ( 'j' ) 3247screen : expect ( [[ 324896 | 324997 | 325098 | 325199 | 3252| 3253{4:-- More --}^ | 3254]] ) 3255feed ( 'j' ) 3256screen : expect ( [[ 325796 | 325897 | 325998 | 326099 | 3261| 3262{4:Press ENTER or type command to continue}^ | 3263]] ) 3264end 3265end ) 3266 3267it ( 'scrolling works properly when :!cmd output ends with newline #27902' , function () 3268screen : try_resize ( 60 , 6 ) 3269api . nvim_set_option_value ( 'shell' , testprg ( 'shell-test' ), {} ) 3270api . nvim_set_option_value ( 'shellcmdflag' , 'REP 100' , {} ) 3271api . nvim_set_option_value ( 'shellxquote' , '' , {} ) -- win: avoid extra quotes 3272feed ( [[:!foo<CR>]] ) 3273screen : expect ( [[ 327496: foo | 327597: foo | 327698: foo | 327799: foo | 3278| 3279{4:Press ENTER or type command to continue}^ | 3280]] ) 3281for _ =1 , 3 do 3282feed ( 'k' ) 3283screen : expect ( [[ 328495: foo | 328596: foo | 328697: foo | 328798: foo | 328899: foo | 3289{4:-- More --}^ | 3290]] ) 3291feed ( 'k' ) 3292screen : expect ( [[ 329394: foo | 329495: foo | 329596: foo | 329697: foo | 329798: foo | 3298{4:-- More --}^ | 3299]] ) 3300feed ( 'j' ) 3301screen : expect ( [[ 330295: foo | 330396: foo | 330497: foo | 330598: foo | 330699: foo | 3307{4:-- More --}^ | 3308]] ) 3309feed ( 'j' ) 3310screen : expect ( [[ 331196: foo | 331297: foo | 331398: foo | 331499: foo | 3315| 3316{4:-- More --}^ | 3317]] ) 3318feed ( 'j' ) 3319screen : expect ( [[ 332096: foo | 332197: foo | 332298: foo | 332399: foo | 3324| 3325{4:Press ENTER or type command to continue}^ | 3326]] ) 3327end 3328end ) 3329end ) 3330 3331it ( 'pager works in headless mode with UI attached' , function () 3332clear () 3333local child_server =assert ( n . new_pipename ()) 3334fn . jobstart ( { nvim_prog , '--clean' , '--headless' , '--listen' , child_server } ) 3335retry ( nil , nil , function () 3336neq ( nil , vim . uv . fs_stat ( child_server )) 3337end ) 3338 3339local child_session =n . connect ( child_server ) 3340local child_screen =Screen . new ( 40 , 6 , nil , child_session ) 3341child_screen . _default_attr_ids =nil -- TODO: unskip with new color scheme 3342 3343child_session : notify ( 'nvim_command' , [[echo range(100)->join("\n")]] ) 3344child_screen : expect ( [[ 33450 | 33461 | 33472 | 33483 | 33494 | 3350-- More --^ | 3351]] ) 3352 3353child_session : request ( 'nvim_input' , 'G' ) 3354child_screen : expect ( [[ 335595 | 335696 | 335797 | 335898 | 335999 | 3360Press ENTER or type command to continue^ | 3361]] ) 3362 3363child_session : request ( 'nvim_input' , 'g' ) 3364child_screen : expect ( [[ 33650 | 33661 | 33672 | 33683 | 33694 | 3370-- More --^ | 3371]] ) 3372end ) 3373 3374describe ( 'progress-message' , function () 3375local screen 3376 3377local function setup_autocmd ( pattern ) 3378exec_lua ( function () 3379local grp =vim . api . nvim_create_augroup ( 'ProgressListener' , { clear =true } ) 3380_G . progress_autocmd_result =nil 3381vim . api . nvim_create_autocmd ( 'Progress' , { 3382pattern =pattern , 3383group =grp , 3384callback =function ( ev ) 3385_G . progress_autocmd_result =ev . data 3386end , 3387} ) 3388end ) 3389end 3390 3391local function assert_progress_autocmd ( expected , context ) 3392local progress_autocmd_result =exec_lua ( function () 3393return _G . progress_autocmd_result 3394end ) 3395eq ( expected , progress_autocmd_result , context ) 3396exec_lua ( function () 3397_G . progress_autocmd_result =nil 3398end ) 3399end 3400 3401local function setup_screen ( with_ext_msg ) 3402if with_ext_msg then 3403screen =Screen . new ( 25 , 5 , { ext_messages =true } ) 3404screen : add_extra_attr_ids { 3405[ 100 ] ={ undercurl =true , special =Screen . colors . Red } , 3406[ 101 ] ={ foreground =Screen . colors . Magenta1 , bold =true } , 3407[ 102 ] ={ foreground =Screen . colors . NvimDarkGreen } , 3408} 3409else 3410screen =Screen . new ( 40 , 5 ) 3411end 3412end 3413 3414before_each ( function () 3415clear () 3416setup_screen ( true ) 3417setup_autocmd () 3418end ) 3419 3420it ( 'emitted by nvim_echo' , function () 3421local id =api . nvim_echo ( 3422{ { 'test-message' } } , 3423true , 3424{ kind ='progress' , title ='testsuit' , percent =10 , status ='running' , source ='tests' } 3425) 3426 3427screen : expect ( { 3428grid =[[ 3429^ | 3430{1:~ }|*4 3431]] , 3432messages ={ 3433{ 3434content ={ 3435{ 'testsuit' , 6 , 'MoreMsg' } , 3436{ ': ' } , 3437{ ' 10% ' , 19 , 'WarningMsg' } , 3438{ 'test-message' } , 3439} , 3440history =true , 3441id =1 , 3442kind ='progress' , 3443} , 3444} , 3445} ) 3446assert_progress_autocmd ( { 3447text ={ 'test-message' } , 3448percent =10 , 3449source ='tests' , 3450status ='running' , 3451title ='testsuit' , 3452id =1 , 3453data ={} , 3454} , 'progress autocmd receives progress messages' ) 3455 3456-- can update progress messages 3457api . nvim_echo ( { { 'test-message-updated' } } , true , { 3458id =id , 3459kind ='progress' , 3460source ='tests' , 3461title ='TestSuit' , 3462percent =50 , 3463status ='running' , 3464} ) 3465screen : expect ( { 3466grid =[[ 3467^ | 3468{1:~ }|*4 3469]] , 3470messages ={ 3471{ 3472content ={ 3473{ 'TestSuit' , 6 , 'MoreMsg' } , 3474{ ': ' } , 3475{ ' 50% ' , 19 , 'WarningMsg' } , 3476{ 'test-message-updated' } , 3477} , 3478history =true , 3479id =1 , 3480kind ='progress' , 3481} , 3482} , 3483} ) 3484 3485assert_progress_autocmd ( { 3486text ={ 'test-message-updated' } , 3487percent =50 , 3488source ='tests' , 3489status ='running' , 3490title ='TestSuit' , 3491id =1 , 3492data ={} , 3493} , 'Progress autocmd receives progress update' ) 3494 3495-- success status 3496api . nvim_echo ( 3497{ { 'test-message (success)' } } , 3498true , 3499{ kind ='progress' , source ='tests' , title ='TestSuit' , percent =100 , status ='success' } 3500) 3501screen : expect ( { 3502grid =[[ 3503^ | 3504{1:~ }|*4 3505]] , 3506messages ={ 3507{ 3508content ={ 3509{ 'TestSuit' , 102 , 'OkMsg' } , 3510{ ': ' } , 3511{ '100% ' , 19 , 'WarningMsg' } , 3512{ 'test-message (success)' } , 3513} , 3514history =true , 3515id =2 , 3516kind ='progress' , 3517} , 3518} , 3519} ) 3520 3521-- failed status 3522api . nvim_echo ( 3523{ { 'test-message (fail)' } } , 3524true , 3525{ kind ='progress' , source ='tests' , title ='TestSuit' , percent =35 , status ='failed' } 3526) 3527screen : expect ( { 3528grid =[[ 3529^ | 3530{1:~ }|*4 3531]] , 3532messages ={ 3533{ 3534content ={ 3535{ 'TestSuit' , 9 , 'ErrorMsg' } , 3536{ ': ' } , 3537{ ' 35% ' , 19 , 'WarningMsg' } , 3538{ 'test-message (fail)' } , 3539} , 3540history =true , 3541id =3 , 3542kind ='progress' , 3543} , 3544} , 3545} ) 3546 3547-- cancel status 3548api . nvim_echo ( 3549{ { 'test-message (cancel)' } } , 3550true , 3551{ kind ='progress' , source ='tests' , title ='TestSuit' , percent =30 , status ='cancel' } 3552) 3553screen : expect ( { 3554grid =[[ 3555^ | 3556{1:~ }|*4 3557]] , 3558messages ={ 3559{ 3560content ={ 3561{ 'TestSuit' , 19 , 'WarningMsg' } , 3562{ ': ' } , 3563{ ' 30% ' , 19 , 'WarningMsg' } , 3564{ 'test-message (cancel)' } , 3565} , 3566history =true , 3567id =4 , 3568kind ='progress' , 3569} , 3570} , 3571} ) 3572 3573-- without title and percent 3574api . nvim_echo ( 3575{ { 'test-message (no-tile or percent)' } } , 3576true , 3577{ kind ='progress' , source ='tests' , status ='cancel' } 3578) 3579screen : expect ( { 3580grid =[[ 3581^ | 3582{1:~ }|*4 3583]] , 3584messages ={ 3585{ 3586content ={ { 'test-message (no-tile or percent)' } } , 3587history =true , 3588id =5 , 3589kind ='progress' , 3590} , 3591} , 3592} ) 3593 3594-- progress event can filter by source 3595setup_autocmd ( 'Tests' ) 3596api . nvim_echo ( 3597{ { 'test-message-updated' } } , 3598true , 3599{ id =id , kind ='progress' , source ='other_source' , percent =80 , status ='running' } 3600) 3601assert_progress_autocmd ( nil , 'No progress message with Tests source yet' ) 3602 3603api . nvim_echo ( { { 'test-message-updated' } } , true , { 3604id =id , 3605kind ='progress' , 3606title ='Title' , 3607percent =100 , 3608status ='success' , 3609source ='Tests' , 3610} ) 3611assert_progress_autocmd ( { 3612text ={ 'test-message-updated' } , 3613percent =100 , 3614source ='Tests' , 3615status ='success' , 3616title ='Title' , 3617id =1 , 3618data ={} , 3619} , 'Progress autocmd receives progress update' ) 3620end ) 3621 3622it ( 'user-defined data' , function () 3623api . nvim_echo ( { { 'test-message' } } , true , { 3624kind ='progress' , 3625title ='TestSuit' , 3626percent =10 , 3627source ='tests' , 3628status ='running' , 3629data ={ test_attribute =1 } , 3630} ) 3631 3632screen : expect ( { 3633grid =[[ 3634^ | 3635{1:~ }|*4 3636]] , 3637messages ={ 3638{ 3639content ={ 3640{ 'TestSuit' , 6 , 'MoreMsg' } , 3641{ ': ' } , 3642{ ' 10% ' , 19 , 'WarningMsg' } , 3643{ 'test-message' } , 3644} , 3645history =true , 3646id =1 , 3647kind ='progress' , 3648} , 3649} , 3650} ) 3651assert_progress_autocmd ( { 3652text ={ 'test-message' } , 3653percent =10 , 3654source ='tests' , 3655status ='running' , 3656title ='TestSuit' , 3657id =1 , 3658data ={ test_attribute =1 } , 3659} , 'Progress autocmd receives progress messages' ) 3660end ) 3661 3662it ( 'validation' , function () 3663-- throws error if title, status, percent, data is used in non progress message 3664eq ( 3665"Conflict: title/source/status/percent/data not allowed with kind='echo'" , 3666t . pcall_err ( api . nvim_echo , { { 'test-message' } } , false , { title ='TestSuit' } ) 3667) 3668 3669eq ( 3670"Conflict: title/source/status/percent/data not allowed with kind='echo'" , 3671t . pcall_err ( api . nvim_echo , { { 'test-message' } } , false , { status ='running' } ) 3672) 3673 3674eq ( 3675"Conflict: title/source/status/percent/data not allowed with kind='echo'" , 3676t . pcall_err ( api . nvim_echo , { { 'test-message' } } , false , { percent =0 } ) 3677) 3678 3679eq ( 3680"Conflict: title/source/status/percent/data not allowed with kind='echo'" , 3681t . pcall_err ( api . nvim_echo , { { 'test-message' } } , false , { data ={ tag ='test' } } ) 3682) 3683 3684eq ( 3685"Conflict: title/source/status/percent/data not allowed with kind='echo'" , 3686t . pcall_err ( api . nvim_echo , { { 'test-message' } } , false , { source ='tests' } ) 3687) 3688 3689-- throws error if anything other then running/success/failed/cancel is used in status 3690eq ( 3691"Invalid 'status': expected success|failed|running|cancel, got live" , 3692t . pcall_err ( 3693api . nvim_echo , 3694{ { 'test-message' } } , 3695false , 3696{ kind ='progress' , source ='tests' , status ='live' } 3697) 3698) 3699 3700-- throws error if parcent is not in 0-100 3701eq ( 3702"Invalid 'percent': out of range" , 3703t . pcall_err ( 3704api . nvim_echo , 3705{ { 'test-message' } } , 3706false , 3707{ kind ='progress' , source ='tests' , status ='running' , percent =- 1 } 3708) 3709) 3710 3711eq ( 3712"Invalid 'percent': out of range" , 3713t . pcall_err ( 3714api . nvim_echo , 3715{ { 'test-message' } } , 3716false , 3717{ kind ='progress' , source ='tests' , status ='running' , percent =101 } 3718) 3719) 3720 3721-- throws error if data is not a dictionary 3722eq ( 3723"Invalid 'data': expected Dict, got String" , 3724t . pcall_err ( api . nvim_echo , { { 'test-message' } } , false , { 3725kind ='progress' , 3726source ='tests' , 3727title ='TestSuit' , 3728percent =10 , 3729status ='running' , 3730data ='test' , 3731} ) 3732) 3733 3734-- throws error if source is not given 3735eq ( 3736"Required: 'opts.source'" , 3737t . pcall_err ( 3738api . nvim_echo , 3739{ { 'test-message' } } , 3740false , 3741{ kind ='progress' , status ='running' } 3742) 3743) 3744end ) 3745 3746it ( 'gets placed in history' , function () 3747local id =api . nvim_echo ( 3748{ { 'test-message 10' } } , 3749true , 3750{ kind ='progress' , source ='tests' , title ='TestSuit' , percent =10 , status ='running' } 3751) 3752eq ( 'TestSuit: 10% test-message 10' , exec_capture ( 'messages' )) 3753 3754api . nvim_echo ( { { 'test-message 20' } } , true , { 3755id =id , 3756kind ='progress' , 3757source ='tests' , 3758title ='TestSuit' , 3759percent =20 , 3760status ='running' , 3761} ) 3762eq ( 'TestSuit: 10% test-message 10\nTestSuit: 20% test-message 20' , exec_capture ( 'messages' )) 3763 3764api . nvim_echo ( { { 'middle msg' } } , true , {} ) 3765eq ( 3766'TestSuit: 10% test-message 10\nTestSuit: 20% test-message 20\nmiddle msg' , 3767exec_capture ( 'messages' ) 3768) 3769api . nvim_echo ( { { 'test-message 30' } } , true , { 3770id =id , 3771kind ='progress' , 3772source ='tests' , 3773title ='TestSuit' , 3774percent =30 , 3775status ='running' , 3776} ) 3777eq ( 3778'TestSuit: 10% test-message 10\nTestSuit: 20% test-message 20\nmiddle msg\nTestSuit: 30% test-message 30' , 3779exec_capture ( 'messages' ) 3780) 3781 3782api . nvim_echo ( { { 'test-message 50' } } , true , { 3783id =id , 3784kind ='progress' , 3785source ='tests' , 3786title ='TestSuit' , 3787percent =50 , 3788status ='running' , 3789} ) 3790eq ( 3791'TestSuit: 10% test-message 10\nTestSuit: 20% test-message 20\nmiddle msg\nTestSuit: 30% test-message 30\nTestSuit: 50% test-message 50' , 3792exec_capture ( 'messages' ) 3793) 3794end ) 3795 3796it ( 'sets msg-id correctly' , function () 3797local id1 =api . nvim_echo ( 3798{ { 'test-message 10' } } , 3799true , 3800{ kind ='progress' , source ='tests' , title ='TestSuit' , percent =10 , status ='running' } 3801) 3802eq ( 1 , id1 ) 3803 3804local id2 =api . nvim_echo ( 3805{ { 'test-message 20' } } , 3806true , 3807{ kind ='progress' , source ='tests' , title ='TestSuit' , percent =20 , status ='running' } 3808) 3809eq ( 2 , id2 ) 3810 3811local id3 =api . nvim_echo ( { { 'normal message' } } , true , {} ) 3812eq ( 3 , id3 ) 3813 3814local id4 =api . nvim_echo ( { { 'without history' } } , false , {} ) 3815eq ( 4 , id4 ) 3816 3817local id5 =api . nvim_echo ( 3818{ { 'test-message 30' } } , 3819true , 3820{ kind ='progress' , source ='tests' , title ='TestSuit' , percent =30 , status ='running' } 3821) 3822eq ( 5 , id5 ) 3823 3824-- updating progress message does not create new msg-id 3825local id5_update =api . nvim_echo ( { { 'test-message 40' } } , true , { 3826id =id5 , 3827kind ='progress' , 3828source ='tests' , 3829title ='TestSuit' , 3830percent =40 , 3831status ='running' , 3832} ) 3833eq ( id5 , id5_update ) 3834 3835local id6 =api . nvim_echo ( 3836{ { 'test-message 30' } } , 3837true , 3838{ kind ='progress' , source ='tests' , title ='TestSuit' , percent =30 , status ='running' } 3839) 3840eq ( 6 , id6 ) 3841 3842local id7 =api . nvim_echo ( { { 'supports str-id' } } , true , { 3843id ='str-id' , 3844kind ='progress' , 3845source ='tests' , 3846title ='TestSuit' , 3847percent =30 , 3848status ='running' , 3849} ) 3850eq ( 'str-id' , id7 ) 3851 3852-- internal messages are also assigned an ID (and thus advance the next progress ID) 3853feed ( '@@' ) 3854local id8 =api . nvim_echo ( 3855{ { 'test-message 30' } } , 3856true , 3857{ kind ='progress' , source ='tests' , title ='TestSuit' , percent =30 , status ='running' } 3858) 3859eq ( 8 , id8 ) 3860end ) 3861 3862it ( 'msg-id is not inherited by the next message #41417' , function () 3863local fname ='Xtest_progress_msgid' 3864finally ( function () 3865os . remove ( fname ) 3866end ) 3867-- The write emits nothing ('msg_silent'), but must still release its msg-id. 3868command ( 'silent write ' .. fname ) 3869feed ( ':echoerr "boom"<CR>' ) 3870screen : expect ( { 3871messages ={ 3872{ 3873content ={ { 'boom' , 9 , 'ErrorMsg' } } , 3874history =true , 3875id =1 , 3876kind ='echoerr' , 3877} , 3878} , 3879} ) 3880end ) 3881 3882it ( 'accepts caller-defined id (string)' , function () 3883-- string id works 3884local id =api . nvim_echo ( { { 'supports str-id' } } , true , { 3885id ='str-id' , 3886kind ='progress' , 3887source ='tests' , 3888title ='TestSuit' , 3889percent =30 , 3890status ='running' , 3891} ) 3892eq ( 'str-id' , id ) 3893 3894screen : expect ( { 3895grid =[[ 3896^ | 3897{1:~ }|*4 3898]] , 3899messages ={ 3900{ 3901content ={ 3902{ 'TestSuit' , 6 , 'MoreMsg' } , 3903{ ': ' } , 3904{ ' 30% ' , 19 , 'WarningMsg' } , 3905{ 'supports str-id' } , 3906} , 3907history =true , 3908id ='str-id' , 3909kind ='progress' , 3910} , 3911} , 3912} ) 3913 3914local id_update =api . nvim_echo ( { { 'supports str-id updated' } } , true , { 3915id =id , 3916kind ='progress' , 3917source ='tests' , 3918title ='testsuit' , 3919percent =40 , 3920status ='running' , 3921} ) 3922eq ( id , id_update ) 3923assert_progress_autocmd ( { 3924text ={ 'supports str-id updated' } , 3925percent =40 , 3926source ='tests' , 3927status ='running' , 3928title ='testsuit' , 3929id ='str-id' , 3930data ={} , 3931} ) 3932end ) 3933 3934it ( 'emitted by :write, not by :read #41193' , function () 3935local fname ='Xtest_progress_bufwrite' 3936finally ( function () 3937os . remove ( fname ) 3938end ) 3939command ( 'write ' .. fname ) 3940assert_progress_autocmd ( { 3941data ={} , 3942id =( 'nvim.bufwrite "%s"' ): format ( fname ), 3943source ='nvim' , 3944status ='success' , 3945text ={ ( '"%s" [New] 0L, 0B written' ): format ( fname ) } , 3946title ='' , 3947} ) 3948 3949-- ":read" is not a write: it must not start a progress that never ends. 3950command ( 'read ' .. fname ) 3951assert_progress_autocmd ( nil ) 3952 3953-- A failed write ends the progress-msg. 3954local events =exec_lua ( function ( f ) 3955local out ={} 3956vim . api . nvim_create_autocmd ( 'Progress' , { 3957callback =function ( ev ) 3958table . insert ( out , { id =ev . data . id , status =ev . data . status , text =ev . data . text [ 1 ] } ) 3959end , 3960} ) 3961pcall ( vim . cmd . write , ( '%s/nodir' ): format ( f )) 3962return out 3963end , fname ) 3964eq ( { 'running' , 'failed' } , { events [ 1 ]. status , events [ 2 ]. status } ) 3965eq ( events [ 1 ]. id , events [ 2 ]. id ) 3966t . matches ( '^E%d+:' , events [ 2 ]. text ) 3967end ) 3968 3969it ( 'emitted by ins-completion scan' , function () 3970fn . writefile ( { 'foobar' , 'foobaz' } , 'Xdict' ) 3971finally ( function () 3972os . remove ( 'Xdict' ) 3973end ) 3974exec_lua ( function () 3975_G . events ={} 3976vim . api . nvim_create_autocmd ( 'Progress' , { 3977callback =function ( ev ) 3978table . insert ( _G . events , ( '%s %s' ): format ( ev . data . id , ev . data . status )) 3979end , 3980} ) 3981end ) 3982command ( 'set shortmess-=C complete=kXdict' ) 3983-- Ends when scanning ends, regardless of whether popupmenu is open. 3984feed ( 'ifoo<C-n>' ) 3985eq ( { 'nvim.completion running' , 'nvim.completion success' } , exec_lua ( 'return _G.events' )) 3986end ) 3987 3988it ( 'tui displays progress message in proper format' , function () 3989clear () 3990setup_screen ( false ) 3991api . nvim_echo ( 3992{ { 'test-message' } } , 3993true , 3994{ kind ='progress' , source ='tests' , title ='TestSuit' , percent =10 , status ='running' } 3995) 3996screen : expect ( [[ 3997^ | 3998{1:~ }|*3 3999{6:TestSuit}: {19: 10% }test-message | 4000]] ) 4001end ) 4002 4003it ( 'works with history off' , function () 4004api . nvim_echo ( { { 'test-message' } } , false , { 4005kind ='progress' , 4006title ='TestSuit' , 4007percent =10 , 4008source ='tests' , 4009status ='running' , 4010} ) 4011 4012screen : expect ( { 4013grid =[[ 4014^ | 4015{1:~ }|*4 4016]] , 4017messages ={ 4018{ 4019content ={ 4020{ 'TestSuit' , 6 , 'MoreMsg' } , 4021{ ': ' } , 4022{ ' 10% ' , 19 , 'WarningMsg' } , 4023{ 'test-message' } , 4024} , 4025id =1 , 4026kind ='progress' , 4027} , 4028} , 4029} ) 4030 4031assert_progress_autocmd ( { 4032text ={ 'test-message' } , 4033percent =10 , 4034source ='tests' , 4035status ='running' , 4036title ='TestSuit' , 4037id =1 , 4038data ={} , 4039} , 'progress autocmd receives progress messages' ) 4040end ) 4041 4042it ( 'can be hidden from cmdline with messagesopt-=progress:c' , function () 4043exec ( 'set messagesopt-=progress:c' ) 4044api . nvim_echo ( 4045{ { 'test-message: not shown in cmdline' } } , 4046true , 4047{ kind ='progress' , source ='tests' , title ='TestSuite' , percent =10 , status ='running' } 4048) 4049screen : expect ( [[ 4050^ | 4051{1:~ }|*4 4052]] ) 4053 4054assert_progress_autocmd ( { 4055text ={ 'test-message: not shown in cmdline' } , 4056percent =10 , 4057source ='tests' , 4058status ='running' , 4059title ='TestSuite' , 4060id =1 , 4061data ={} , 4062} , 'progress autocmd still receives progress even with progress messages hidden from cmd' ) 4063 4064exec ( 'set messagesopt+=progress:c' ) 4065api . nvim_echo ( 4066{ { 'test-message: shown in cmdline' } } , 4067true , 4068{ kind ='progress' , source ='tests' , title ='TestSuite' , percent =10 , status ='running' } 4069) 4070screen : expect ( { 4071grid =[[ 4072^ | 4073{1:~ }|*4 4074]] , 4075messages ={ 4076{ 4077content ={ 4078{ 'TestSuite' , 6 , 'MoreMsg' } , 4079{ ': ' } , 4080{ ' 10% ' , 19 , 'WarningMsg' } , 4081{ 'test-message: shown in cmdline' } , 4082} , 4083history =true , 4084id =2 , 4085kind ='progress' , 4086} , 4087} , 4088} ) 4089 4090assert_progress_autocmd ( { 4091text ={ 'test-message: shown in cmdline' } , 4092percent =10 , 4093source ='tests' , 4094status ='running' , 4095title ='TestSuite' , 4096id =2 , 4097data ={} , 4098} , 'progress autocmd still receives progresswith progress messages shown in cmd' ) 4099end ) 4100end )