robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3local Screen =require ( 'test.functional.ui.screen' ) 4 5local describe , it , before_each =t . describe , t . it , t . before_each 6local assert_alive =n . assert_alive 7local clear , feed =n . clear , n . feed 8local source =n . source 9local insert =n . insert 10local api =n . api 11local async_meths =n . async_meths 12local command =n . command 13local fn =n . fn 14local eq =t . eq 15local pcall_err =t . pcall_err 16local exec_lua =n . exec_lua 17local exec =n . exec 18local poke_eventloop =n . poke_eventloop 19 20describe ( 'ui/ext_popupmenu' , function () 21local screen 22before_each ( function () 23clear () 24screen =Screen . new ( 60 , 8 , { rgb =true , ext_popupmenu =true } ) 25source ( [[ 26function! TestComplete() abort 27call complete(1, [{'word':'foo', 'abbr':'fo', 'menu':'the foo', 'info':'foo-y', 'kind':'x'}, 'bar', 'spam']) 28return '' 29endfunction 30]] ) 31end ) 32 33local expected ={ 34{ 'fo' , 'x' , 'the foo' , 'foo-y' } , 35{ 'bar' , '' , '' , '' } , 36{ 'spam' , '' , '' , '' } , 37} 38 39it ( 'works' , function () 40feed ( 'o<C-r>=TestComplete()<CR>' ) 41screen : expect { 42grid =[[ 43| 44foo^ | 45{1:~ }|*5 46{5:-- INSERT --} | 47]] , 48popupmenu ={ items =expected , pos =0 , anchor ={ 1 , 1 , 0 } } , 49} 50 51feed ( '<c-p>' ) 52screen : expect { 53grid =[[ 54| 55^ | 56{1:~ }|*5 57{5:-- INSERT --} | 58]] , 59popupmenu ={ items =expected , pos =- 1 , anchor ={ 1 , 1 , 0 } } , 60} 61 62-- down moves the selection in the menu, but does not insert anything 63feed ( '<down><down>' ) 64screen : expect { 65grid =[[ 66| 67^ | 68{1:~ }|*5 69{5:-- INSERT --} | 70]] , 71popupmenu ={ items =expected , pos =1 , anchor ={ 1 , 1 , 0 } } , 72} 73 74feed ( '<cr>' ) 75screen : expect ( [[ 76| 77bar^ | 78{1:~ }|*5 79{5:-- INSERT --} | 80]] ) 81end ) 82 83it ( 'can be controlled by API' , function () 84feed ( 'o<C-r>=TestComplete()<CR>' ) 85screen : expect { 86grid =[[ 87| 88foo^ | 89{1:~ }|*5 90{5:-- INSERT --} | 91]] , 92popupmenu ={ items =expected , pos =0 , anchor ={ 1 , 1 , 0 } } , 93} 94 95api . nvim_select_popupmenu_item ( 1 , false , false , {} ) 96screen : expect { 97grid =[[ 98| 99foo^ | 100{1:~ }|*5 101{5:-- INSERT --} | 102]] , 103popupmenu ={ items =expected , pos =1 , anchor ={ 1 , 1 , 0 } } , 104} 105 106api . nvim_select_popupmenu_item ( 2 , true , false , {} ) 107screen : expect { 108grid =[[ 109| 110spam^ | 111{1:~ }|*5 112{5:-- INSERT --} | 113]] , 114popupmenu ={ items =expected , pos =2 , anchor ={ 1 , 1 , 0 } } , 115} 116 117api . nvim_select_popupmenu_item ( 0 , true , true , {} ) 118screen : expect ( [[ 119| 120foo^ | 121{1:~ }|*5 122{5:-- INSERT --} | 123]] ) 124 125feed ( '<c-w><C-r>=TestComplete()<CR>' ) 126screen : expect { 127grid =[[ 128| 129foo^ | 130{1:~ }|*5 131{5:-- INSERT --} | 132]] , 133popupmenu ={ items =expected , pos =0 , anchor ={ 1 , 1 , 0 } } , 134} 135 136api . nvim_select_popupmenu_item ( - 1 , false , false , {} ) 137screen : expect { 138grid =[[ 139| 140foo^ | 141{1:~ }|*5 142{5:-- INSERT --} | 143]] , 144popupmenu ={ items =expected , pos =- 1 , anchor ={ 1 , 1 , 0 } } , 145} 146 147api . nvim_select_popupmenu_item ( 1 , true , false , {} ) 148screen : expect { 149grid =[[ 150| 151bar^ | 152{1:~ }|*5 153{5:-- INSERT --} | 154]] , 155popupmenu ={ items =expected , pos =1 , anchor ={ 1 , 1 , 0 } } , 156} 157 158api . nvim_select_popupmenu_item ( - 1 , true , false , {} ) 159screen : expect { 160grid =[[ 161| 162^ | 163{1:~ }|*5 164{5:-- INSERT --} | 165]] , 166popupmenu ={ items =expected , pos =- 1 , anchor ={ 1 , 1 , 0 } } , 167} 168 169api . nvim_select_popupmenu_item ( 0 , true , false , {} ) 170screen : expect { 171grid =[[ 172| 173foo^ | 174{1:~ }|*5 175{5:-- INSERT --} | 176]] , 177popupmenu ={ items =expected , pos =0 , anchor ={ 1 , 1 , 0 } } , 178} 179 180api . nvim_select_popupmenu_item ( - 1 , true , true , {} ) 181screen : expect ( [[ 182| 183^ | 184{1:~ }|*5 185{5:-- INSERT --} | 186]] ) 187 188command ( 'set wildmenu' ) 189command ( 'set wildoptions=pum' ) 190local expected_wildpum ={ 191{ 'define' , '' , '' , '' } , 192{ 'jump' , '' , '' , '' } , 193{ 'list' , '' , '' , '' } , 194{ 'place' , '' , '' , '' } , 195{ 'undefine' , '' , '' , '' } , 196{ 'unplace' , '' , '' , '' } , 197} 198feed ( '<Esc>:sign <Tab>' ) 199screen : expect ( { 200grid =[[ 201|*2 202{1:~ }|*5 203:sign define^ | 204]] , 205popupmenu ={ items =expected_wildpum , pos =0 , anchor ={ 1 , 7 , 6 } } , 206} ) 207 208api . nvim_select_popupmenu_item ( - 1 , true , false , {} ) 209screen : expect ( { 210grid =[[ 211|*2 212{1:~ }|*5 213:sign ^ | 214]] , 215popupmenu ={ items =expected_wildpum , pos =- 1 , anchor ={ 1 , 7 , 6 } } , 216} ) 217 218api . nvim_select_popupmenu_item ( 5 , true , false , {} ) 219screen : expect ( { 220grid =[[ 221|*2 222{1:~ }|*5 223:sign unplace^ | 224]] , 225popupmenu ={ items =expected_wildpum , pos =5 , anchor ={ 1 , 7 , 6 } } , 226} ) 227 228api . nvim_select_popupmenu_item ( - 1 , true , true , {} ) 229screen : expect ( { 230grid =[[ 231|*2 232{1:~ }|*5 233:sign ^ | 234]] , 235} ) 236 237feed ( '<Tab>' ) 238screen : expect ( { 239grid =[[ 240|*2 241{1:~ }|*5 242:sign define^ | 243]] , 244popupmenu ={ items =expected_wildpum , pos =0 , anchor ={ 1 , 7 , 6 } } , 245} ) 246 247api . nvim_select_popupmenu_item ( 5 , true , true , {} ) 248screen : expect ( [[ 249|*2 250{1:~ }|*5 251:sign unplace^ | 252]] ) 253 254local function test_pum_select_mappings () 255screen : set_option ( 'ext_popupmenu' , true ) 256feed ( '<Esc>A<C-r>=TestComplete()<CR>' ) 257screen : expect { 258grid =[[ 259| 260foo^ | 261{1:~ }|*5 262{5:-- INSERT --} | 263]] , 264popupmenu ={ items =expected , pos =0 , anchor ={ 1 , 1 , 0 } } , 265} 266 267feed ( '<f1>' ) 268screen : expect { 269grid =[[ 270| 271spam^ | 272{1:~ }|*5 273{5:-- INSERT --} | 274]] , 275popupmenu ={ items =expected , pos =2 , anchor ={ 1 , 1 , 0 } } , 276} 277 278feed ( '<f2>' ) 279screen : expect { 280grid =[[ 281| 282spam^ | 283{1:~ }|*5 284{5:-- INSERT --} | 285]] , 286popupmenu ={ items =expected , pos =- 1 , anchor ={ 1 , 1 , 0 } } , 287} 288 289feed ( '<f3>' ) 290screen : expect ( [[ 291| 292bar^ | 293{1:~ }|*5 294{5:-- INSERT --} | 295]] ) 296 297feed ( '<Esc>:sign <Tab>' ) 298screen : expect ( { 299grid =[[ 300| 301bar | 302{1:~ }|*5 303:sign define^ | 304]] , 305popupmenu ={ items =expected_wildpum , pos =0 , anchor ={ 1 , 7 , 6 } } , 306} ) 307 308feed ( '<f1>' ) 309screen : expect ( { 310grid =[[ 311| 312bar | 313{1:~ }|*5 314:sign list^ | 315]] , 316popupmenu ={ items =expected_wildpum , pos =2 , anchor ={ 1 , 7 , 6 } } , 317} ) 318 319feed ( '<f2>' ) 320screen : expect ( { 321grid =[[ 322| 323bar | 324{1:~ }|*5 325:sign ^ | 326]] , 327popupmenu ={ items =expected_wildpum , pos =- 1 , anchor ={ 1 , 7 , 6 } } , 328} ) 329 330feed ( '<f3>' ) 331screen : expect ( { 332grid =[[ 333| 334bar | 335{1:~ }|*5 336:sign jump^ | 337]] , 338} ) 339 340-- also should work for builtin popupmenu 341screen : set_option ( 'ext_popupmenu' , false ) 342feed ( '<Esc>A<C-r>=TestComplete()<CR>' ) 343screen : expect ( [[ 344| 345foo^ | 346{12:fo x the foo }{1: }| 347{4:bar }{1: }| 348{4:spam }{1: }| 349{1:~ }|*2 350{5:-- INSERT --} | 351]] ) 352 353feed ( '<f1>' ) 354screen : expect ( [[ 355| 356spam^ | 357{4:fo x the foo }{1: }| 358{4:bar }{1: }| 359{12:spam }{1: }| 360{1:~ }|*2 361{5:-- INSERT --} | 362]] ) 363 364feed ( '<f2>' ) 365screen : expect ( [[ 366| 367spam^ | 368{4:fo x the foo }{1: }| 369{4:bar }{1: }| 370{4:spam }{1: }| 371{1:~ }|*2 372{5:-- INSERT --} | 373]] ) 374 375feed ( '<f3>' ) 376screen : expect ( [[ 377| 378bar^ | 379{1:~ }|*5 380{5:-- INSERT --} | 381]] ) 382 383feed ( '<Esc>:sign <Tab>' ) 384screen : expect ( [[ 385| 386bar {12: define } | 387{1:~ }{4: jump }{1: }| 388{1:~ }{4: list }{1: }| 389{1:~ }{4: place }{1: }| 390{1:~ }{4: undefine }{1: }| 391{1:~ }{4: unplace }{1: }| 392:sign define^ | 393]] ) 394 395feed ( '<f1>' ) 396screen : expect ( [[ 397| 398bar {4: define } | 399{1:~ }{4: jump }{1: }| 400{1:~ }{12: list }{1: }| 401{1:~ }{4: place }{1: }| 402{1:~ }{4: undefine }{1: }| 403{1:~ }{4: unplace }{1: }| 404:sign list^ | 405]] ) 406 407feed ( '<f2>' ) 408screen : expect ( [[ 409| 410bar {4: define } | 411{1:~ }{4: jump }{1: }| 412{1:~ }{4: list }{1: }| 413{1:~ }{4: place }{1: }| 414{1:~ }{4: undefine }{1: }| 415{1:~ }{4: unplace }{1: }| 416:sign ^ | 417]] ) 418 419feed ( '<f3>' ) 420screen : expect ( [[ 421| 422bar | 423{1:~ }|*5 424:sign jump^ | 425]] ) 426end 427 428command ( 'map! <f1> <cmd>call nvim_select_popupmenu_item(2,v:true,v:false,{})<cr>' ) 429command ( 'map! <f2> <cmd>call nvim_select_popupmenu_item(-1,v:false,v:false,{})<cr>' ) 430command ( 'map! <f3> <cmd>call nvim_select_popupmenu_item(1,v:false,v:true,{})<cr>' ) 431test_pum_select_mappings () 432 433command ( 'unmap! <f1>' ) 434command ( 'unmap! <f2>' ) 435command ( 'unmap! <f3>' ) 436exec_lua ( [[ 437vim.keymap.set('!', '<f1>', function() vim.api.nvim_select_popupmenu_item(2, true, false, {}) end) 438vim.keymap.set('!', '<f2>', function() vim.api.nvim_select_popupmenu_item(-1, false, false, {}) end) 439vim.keymap.set('!', '<f3>', function() vim.api.nvim_select_popupmenu_item(1, false, true, {}) end) 440]] ) 441test_pum_select_mappings () 442 443feed ( '<esc>ddiaa bb cc<cr>' ) 444feed ( '<c-x><c-n>' ) 445screen : expect ( [[ 446aa bb cc | 447aa^ | 448{12:aa }{1: }| 449{4:bb }{1: }| 450{4:cc }{1: }| 451{1:~ }|*2 452{5:-- Keyword Local completion (^N^P) }{6:match 1 of 3} | 453]] ) 454 455feed ( '<f1>' ) 456screen : expect ( [[ 457aa bb cc | 458cc^ | 459{4:aa }{1: }| 460{4:bb }{1: }| 461{12:cc }{1: }| 462{1:~ }|*2 463{5:-- Keyword Local completion (^N^P) }{6:match 3 of 3} | 464]] ) 465 466feed ( '<f2>' ) 467screen : expect ( [[ 468aa bb cc | 469cc^ | 470{4:aa }{1: }| 471{4:bb }{1: }| 472{4:cc }{1: }| 473{1:~ }|*2 474{5:-- Keyword Local completion (^N^P) }{19:Back at original} | 475]] ) 476 477feed ( '<f3>' ) 478screen : expect ( [[ 479aa bb cc | 480bb^ | 481{1:~ }|*5 482{5:-- INSERT --} | 483]] ) 484end ) 485 486local function source_complete_month () 487source ( [[ 488function! TestCompleteMonth() abort 489call complete(1, ['January', 'February', 'March', 'April', 490\ 'May', 'June', 'July', 'August', 491\ 'September', 'October', 'November', 'December']) 492return '' 493endfunction 494]] ) 495end 496 497describe ( 'pum_set_height' , function () 498it ( 'can set pum height' , function () 499source_complete_month () 500local month_expected ={ 501{ 'January' , '' , '' , '' } , 502{ 'February' , '' , '' , '' } , 503{ 'March' , '' , '' , '' } , 504{ 'April' , '' , '' , '' } , 505{ 'May' , '' , '' , '' } , 506{ 'June' , '' , '' , '' } , 507{ 'July' , '' , '' , '' } , 508{ 'August' , '' , '' , '' } , 509{ 'September' , '' , '' , '' } , 510{ 'October' , '' , '' , '' } , 511{ 'November' , '' , '' , '' } , 512{ 'December' , '' , '' , '' } , 513} 514local pum_height =6 515feed ( 'o<C-r>=TestCompleteMonth()<CR>' ) 516api . nvim_ui_pum_set_height ( pum_height ) 517feed ( '<PageDown>' ) 518-- pos becomes pum_height-2 because it is subtracting 2 to keep some 519-- context in ins_compl_key2count() 520screen : expect { 521grid =[[ 522| 523January^ | 524{1:~ }|*5 525{5:-- INSERT --} | 526]] , 527popupmenu ={ items =month_expected , pos =pum_height - 2 , anchor ={ 1 , 1 , 0 } } , 528} 529end ) 530 531it ( 'an error occurs if set 0 or less' , function () 532api . nvim_ui_pum_set_height ( 1 ) 533eq ( 'Expected pum height > 0' , pcall_err ( api . nvim_ui_pum_set_height , 0 )) 534end ) 535 536it ( 'an error occurs when ext_popupmenu is false' , function () 537api . nvim_ui_pum_set_height ( 1 ) 538screen : set_option ( 'ext_popupmenu' , false ) 539eq ( 'UI must support the ext_popupmenu option' , pcall_err ( api . nvim_ui_pum_set_height , 1 )) 540end ) 541end ) 542 543describe ( 'pum_set_bounds' , function () 544it ( 'can set pum bounds' , function () 545source_complete_month () 546local month_expected ={ 547{ 'January' , '' , '' , '' } , 548{ 'February' , '' , '' , '' } , 549{ 'March' , '' , '' , '' } , 550{ 'April' , '' , '' , '' } , 551{ 'May' , '' , '' , '' } , 552{ 'June' , '' , '' , '' } , 553{ 'July' , '' , '' , '' } , 554{ 'August' , '' , '' , '' } , 555{ 'September' , '' , '' , '' } , 556{ 'October' , '' , '' , '' } , 557{ 'November' , '' , '' , '' } , 558{ 'December' , '' , '' , '' } , 559} 560local pum_height =6 561feed ( 'o<C-r>=TestCompleteMonth()<CR>' ) 562api . nvim_ui_pum_set_height ( pum_height ) 563-- set bounds w h r c 564api . nvim_ui_pum_set_bounds ( 10.5 , 5.2 , 6.3 , 7.4 ) 565feed ( '<PageDown>' ) 566-- pos becomes pum_height-2 because it is subtracting 2 to keep some 567-- context in ins_compl_key2count() 568screen : expect { 569grid =[[ 570| 571January^ | 572{1:~ }|*5 573{5:-- INSERT --} | 574]] , 575popupmenu ={ items =month_expected , pos =pum_height - 2 , anchor ={ 1 , 1 , 0 } } , 576} 577end ) 578 579it ( 'no error occurs if row or col set less than 0' , function () 580api . nvim_ui_pum_set_bounds ( 1.0 , 1.0 , 0.0 , 1.5 ) 581api . nvim_ui_pum_set_bounds ( 1.0 , 1.0 , - 1.0 , 0.0 ) 582api . nvim_ui_pum_set_bounds ( 1.0 , 1.0 , 0.0 , - 1.0 ) 583end ) 584 585it ( 'an error occurs if width or height set 0 or less' , function () 586api . nvim_ui_pum_set_bounds ( 1.0 , 1.0 , 0.0 , 1.5 ) 587eq ( 'Expected width > 0' , pcall_err ( api . nvim_ui_pum_set_bounds , 0.0 , 1.0 , 1.0 , 0.0 )) 588eq ( 'Expected height > 0' , pcall_err ( api . nvim_ui_pum_set_bounds , 1.0 , - 1.0 , 1.0 , 0.0 )) 589end ) 590 591it ( 'an error occurs when ext_popupmenu is false' , function () 592api . nvim_ui_pum_set_bounds ( 1.0 , 1.0 , 0.0 , 1.5 ) 593screen : set_option ( 'ext_popupmenu' , false ) 594eq ( 595'UI must support the ext_popupmenu option' , 596pcall_err ( api . nvim_ui_pum_set_bounds , 1.0 , 1.0 , 0.0 , 1.5 ) 597) 598end ) 599end ) 600 601it ( '<PageUp>, <PageDown> works without ui_pum_set_height' , function () 602source_complete_month () 603local month_expected ={ 604{ 'January' , '' , '' , '' } , 605{ 'February' , '' , '' , '' } , 606{ 'March' , '' , '' , '' } , 607{ 'April' , '' , '' , '' } , 608{ 'May' , '' , '' , '' } , 609{ 'June' , '' , '' , '' } , 610{ 'July' , '' , '' , '' } , 611{ 'August' , '' , '' , '' } , 612{ 'September' , '' , '' , '' } , 613{ 'October' , '' , '' , '' } , 614{ 'November' , '' , '' , '' } , 615{ 'December' , '' , '' , '' } , 616} 617feed ( 'o<C-r>=TestCompleteMonth()<CR>' ) 618feed ( '<PageDown>' ) 619screen : expect { 620grid =[[ 621| 622January^ | 623{1:~ }|*5 624{5:-- INSERT --} | 625]] , 626popupmenu ={ items =month_expected , pos =3 , anchor ={ 1 , 1 , 0 } } , 627} 628feed ( '<PageUp>' ) 629screen : expect { 630grid =[[ 631| 632January^ | 633{1:~ }|*5 634{5:-- INSERT --} | 635]] , 636popupmenu ={ items =month_expected , pos =0 , anchor ={ 1 , 1 , 0 } } , 637} 638end ) 639 640it ( 'works with wildoptions=pum' , function () 641screen : try_resize ( 32 , 10 ) 642command ( 'set wildmenu' ) 643command ( 'set wildoptions=pum' ) 644 645local wild_expected ={ 646{ 'define' , '' , '' , '' } , 647{ 'jump' , '' , '' , '' } , 648{ 'list' , '' , '' , '' } , 649{ 'place' , '' , '' , '' } , 650{ 'undefine' , '' , '' , '' } , 651{ 'unplace' , '' , '' , '' } , 652} 653 654feed ( ':sign ' ) 655screen : expect ( [[ 656| 657{1:~ }|*8 658:sign ^ | 659]] ) 660eq ( 0 , fn . wildmenumode ()) 661 662feed ( '<tab>' ) 663screen : expect { 664grid =[[ 665| 666{1:~ }|*8 667:sign define^ | 668]] , 669popupmenu ={ items =wild_expected , pos =0 , anchor ={ 1 , 9 , 6 } } , 670} 671eq ( 1 , fn . wildmenumode ()) 672 673feed ( '<left>' ) 674screen : expect { 675grid =[[ 676| 677{1:~ }|*8 678:sign ^ | 679]] , 680popupmenu ={ items =wild_expected , pos =- 1 , anchor ={ 1 , 9 , 6 } } , 681} 682 683feed ( '<left>' ) 684screen : expect { 685grid =[[ 686| 687{1:~ }|*8 688:sign unplace^ | 689]] , 690popupmenu ={ items =wild_expected , pos =5 , anchor ={ 1 , 9 , 6 } } , 691} 692 693feed ( 'x' ) 694screen : expect ( [[ 695| 696{1:~ }|*8 697:sign unplacex^ | 698]] ) 699feed ( '<esc>' ) 700 701-- #10042: make sure shift-tab also triggers the pum 702feed ( ':sign <S-tab>' ) 703screen : expect { 704grid =[[ 705| 706{1:~ }|*8 707:sign unplace^ | 708]] , 709popupmenu ={ items =wild_expected , pos =5 , anchor ={ 1 , 9 , 6 } } , 710} 711feed ( '<esc>' ) 712eq ( 0 , fn . wildmenumode ()) 713 714-- check positioning with multibyte char in pattern 715command ( 'e långfile1' ) 716command ( 'sp långfile2' ) 717feed ( ':b lå<tab>' ) 718screen : expect { 719grid =[[ 720| 721{1:~ }|*3 722{3:långfile2 }| 723| 724{1:~ }|*2 725{2:långfile1 }| 726:b långfile1^ | 727]] , 728popupmenu ={ 729anchor ={ 1 , 9 , 3 } , 730items ={ { 'långfile1' , '' , '' , '' } , { 'långfile2' , '' , '' , '' } } , 731pos =0 , 732} , 733} 734end ) 735 736it ( 'does not interfere with mousemodel=popup' , function () 737exec ( [[ 738set mouse=a mousemodel=popup 739 740aunmenu PopUp 741" Delete the default MenuPopup event handler. 742autocmd! nvim.popupmenu 743menu PopUp.foo :let g:menustr = 'foo'<CR> 744menu PopUp.bar :let g:menustr = 'bar'<CR> 745menu PopUp.baz :let g:menustr = 'baz'<CR> 746]] ) 747feed ( 'o<C-r>=TestComplete()<CR>' ) 748screen : expect { 749grid =[[ 750| 751foo^ | 752{1:~ }|*5 753{5:-- INSERT --} | 754]] , 755popupmenu ={ items =expected , pos =0 , anchor ={ 1 , 1 , 0 } } , 756} 757 758feed ( '<c-p>' ) 759screen : expect { 760grid =[[ 761| 762^ | 763{1:~ }|*5 764{5:-- INSERT --} | 765]] , 766popupmenu ={ items =expected , pos =- 1 , anchor ={ 1 , 1 , 0 } } , 767} 768 769feed ( '<esc>' ) 770screen : expect ( [[ 771| 772^ | 773{1:~ }|*5 774| 775]] ) 776feed ( '<RightMouse><0,0>' ) 777screen : expect ( [[ 778| 779{4:^foo } | 780{4:bar }{1: }| 781{4:baz }{1: }| 782{1:~ }|*3 783| 784]] ) 785feed ( '<esc>' ) 786screen : expect ( [[ 787| 788^ | 789{1:~ }|*5 790| 791]] ) 792end ) 793end ) 794 795describe ( "builtin popupmenu 'pumblend'" , function () 796local screen 797before_each ( function () 798clear () 799screen =Screen . new ( 60 , 14 ) 800screen : add_extra_attr_ids ( { 801[ 100 ] ={ background =Screen . colors . Gray55 , foreground =Screen . colors . Grey45 } , 802[ 101 ] ={ background =Screen . colors . Gray55 , foreground =Screen . colors . Grey0 } , 803[ 102 ] ={ background =tonumber ( '0x191919' ), foreground =Screen . colors . Grey0 } , 804[ 103 ] ={ background =tonumber ( '0xffc1ff' ), foreground =tonumber ( '0xe5a8e5' ) } , 805[ 104 ] ={ background =tonumber ( '0xffc1ff' ), foreground =Screen . colors . Grey0 } , 806[ 105 ] ={ foreground =tonumber ( '0xffc1ff' ), background =tonumber ( '0xe5a8e5' ), bold =true } , 807[ 106 ] ={ foreground =Screen . colors . Grey55 , background =Screen . colors . Gray45 , bold =true } , 808[ 107 ] ={ background =tonumber ( '0xffc1e5' ), foreground =Screen . colors . Grey0 } , 809[ 108 ] ={ background =tonumber ( '0xffc1e5' ), foreground =tonumber ( '0xe5a8e5' ) } , 810[ 109 ] ={ background =tonumber ( '0xffc1ff' ), foreground =tonumber ( '0x080202' ) } , 811[ 110 ] ={ background =tonumber ( '0xffc1ff' ), bold =true , foreground =tonumber ( '0xf6ace9' ) } , 812[ 111 ] ={ background =tonumber ( '0xffc1ff' ), foreground =tonumber ( '0xe5a8ff' ) } , 813[ 112 ] ={ background =tonumber ( '0xe5a8e5' ), foreground =tonumber ( '0xffc1ff' ) } , 814[ 113 ] ={ background =Screen . colors . Gray45 , foreground =Screen . colors . Grey55 } , 815[ 114 ] ={ background =Screen . colors . WebGray } , 816[ 115 ] ={ background =Screen . colors . Grey0 } , 817[ 116 ] ={ background =Screen . colors . Gray75 , foreground =Screen . colors . Grey25 } , 818[ 117 ] ={ background =Screen . colors . Gray75 , foreground =Screen . colors . Grey0 } , 819[ 118 ] ={ background =Screen . colors . Gray50 , foreground =Screen . colors . Grey0 } , 820[ 119 ] ={ background =tonumber ( '0xffddff' ), foreground =tonumber ( '0x7f5d7f' ) } , 821[ 120 ] ={ background =tonumber ( '0xffddff' ), foreground =Screen . colors . Grey0 } , 822[ 121 ] ={ foreground =tonumber ( '0xffddff' ), background =tonumber ( '0x7f5d7f' ), bold =true } , 823[ 123 ] ={ foreground =tonumber ( '0xffddff' ), background =Screen . colors . Grey0 , bold =true } , 824[ 124 ] ={ foreground =Screen . colors . Gray75 , background =Screen . colors . Grey25 , bold =true } , 825[ 125 ] ={ background =tonumber ( '0xffdd7f' ), foreground =Screen . colors . Grey0 } , 826[ 126 ] ={ background =tonumber ( '0xffdd7f' ), foreground =tonumber ( '0x7f5d7f' ) } , 827[ 127 ] ={ background =tonumber ( '0xffddff' ), bold =true , foreground =tonumber ( '0x290a0a' ) } , 828[ 128 ] ={ background =tonumber ( '0xffddff' ), bold =true , foreground =tonumber ( '0xd27294' ) } , 829[ 129 ] ={ background =tonumber ( '0xffddff' ), foreground =tonumber ( '0x7f5dff' ) } , 830[ 130 ] ={ background =tonumber ( '0x7f5d7f' ), foreground =tonumber ( '0xffddff' ) } , 831[ 131 ] ={ background =Screen . colors . Grey0 , foreground =tonumber ( '0xffddff' ) } , 832[ 132 ] ={ background =Screen . colors . Gray25 , foreground =Screen . colors . Grey75 } , 833[ 134 ] ={ background =tonumber ( '0xffddff' ), foreground =tonumber ( '0x00003f' ) } , 834[ 135 ] ={ foreground =tonumber ( '0x0c0c0c' ), background =tonumber ( '0xe5a8e5' ) } , 835[ 136 ] ={ background =tonumber ( '0x7f5d7f' ), bold =true , foreground =tonumber ( '0x3f3f3f' ) } , 836[ 137 ] ={ foreground =tonumber ( '0x3f3f3f' ), background =tonumber ( '0x7f5d7f' ) } , 837[ 138 ] ={ background =Screen . colors . WebGray , blend =0 } , 838[ 139 ] ={ background =7 , foreground =Screen . colors . Gray0 } , 839[ 140 ] ={ background =7 , foreground =85 } , 840[ 141 ] ={ background =225 , foreground =Screen . colors . Gray0 } , 841[ 142 ] ={ background =225 , foreground =209 } , 842[ 143 ] ={ foreground =12 } , 843[ 144 ] ={ foreground =2 } , 844[ 145 ] ={ foreground =tonumber ( '0x290a0a' ), background =tonumber ( '0xffddff' ) } , 845} ) 846end ) 847 848it ( 'RGB-color' , function () 849command ( 'syntax on' ) 850command ( 'set mouse=a' ) 851command ( 'set pumblend=10' ) 852insert ( [[ 853Lorem ipsum dolor sit amet, consectetur 854adipisicing elit, sed do eiusmod tempor 855incididunt ut labore et dolore magna aliqua. 856Ut enim ad minim veniam, quis nostrud 857exercitation ullamco laboris nisi ut aliquip ex 858ea commodo consequat. Duis aute irure dolor in 859reprehenderit in voluptate velit esse cillum 860dolore eu fugiat nulla pariatur. Excepteur sint 861occaecat cupidatat non proident, sunt in culpa 862qui officia deserunt mollit anim id est 863laborum.]] ) 864command ( 'match Statement /el/' ) 865command ( '2match Comment /ut/' ) 866command ( '1' ) 867command ( 'split' ) 868command ( '/ol' ) 869screen : expect ( [[ 870Lorem ipsum d{10:ol}or sit amet, consectetur | 871adipisicing elit, sed do eiusmod tempor | 872^incididunt ut labore et d{10:ol}ore magna aliqua. | 873Ut enim ad minim veniam, quis nostrud | 874exercitation ullamco laboris nisi ut aliquip ex | 875ea commodo consequat. Duis aute irure d{10:ol}or in | 876{3:[No Name] [+] }| 877Lorem ipsum d{10:ol}or sit amet, consectetur | 878adipisicing {15:el}it, sed do eiusmod tempor | 879incididunt {18:ut} labore et d{10:ol}ore magna aliqua. | 880Ut enim ad minim veniam, quis nostrud | 881exercitation ullamco laboris nisi {18:ut} aliquip ex | 882{2:[No Name] [+] }| 883| 884]] ) 885 886feed ( 'Obla bla <c-x><c-n>' ) 887screen : expect ( [[ 888Lorem ipsum d{10:ol}or sit amet, consectetur | 889adipisicing elit, sed do eiusmod tempor | 890bla bla incididunt^ | 891incidid{100:u}{101:incididunt}{100:re et}{102: }d{10:ol}ore magna aliqua. | 892Ut enim{103: }{104:ut}{103: minim veniam}{100:,} quis nostrud | 893exercit{103:a}{104:labore}{103:llamco la}{100:b}oris nisi ut aliquip ex | 894{3:[No Nam}{105:e}{135:et}{105:[+] }{106: }{3: }| 895Lorem i{103:p}{104:dolor}{107:e}{108:l}{103:or sit a}{100:m}et, consectetur | 896adipisi{103:c}{104:magn}{109:a}{110:l}{103:it, sed d}{100:o} eiusmod tempor | 897bla bla{103: }{104:aliqua}{103:dunt }{100: } | 898incidid{103:u}{104:Ut}{103: }{111:ut}{103: labore et}{100: }d{10:ol}ore magna aliqua. | 899Ut enim{103: }{104:enim}{103:inim veniam}{100:,} quis nostrud | 900{2:[No Nam}{112:e}{135:ad}{112:[+] }{113: }{2: }| 901{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 902]] ) 903 904command ( 'set pumblend=0' ) 905screen : expect ( [[ 906Lorem ipsum d{10:ol}or sit amet, consectetur | 907adipisicing elit, sed do eiusmod tempor | 908bla bla incididunt^ | 909incidid{114: incididunt }{115: }d{10:ol}ore magna aliqua. | 910Ut enim{4: ut }{114: } quis nostrud | 911exercit{4: labore }{114: }oris nisi ut aliquip ex | 912{3:[No Nam}{4: et }{114: }{3: }| 913Lorem i{4: dolore }{114: }et, consectetur | 914adipisi{4: magna }{114: } eiusmod tempor | 915bla bla{4: aliqua }{114: } | 916incidid{4: Ut }{114: }d{10:ol}ore magna aliqua. | 917Ut enim{4: enim }{114: } quis nostrud | 918{2:[No Nam}{4: ad }{114: }{2: }| 919{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 920]] ) 921 922command ( 'set pumblend=50' ) 923screen : expect ( [[ 924Lorem ipsum d{10:ol}or sit amet, consectetur | 925adipisicing elit, sed do eiusmod tempor | 926bla bla incididunt^ | 927incidid{116:u}{117:incididunt}{116:re et}{118: }d{10:ol}ore magna aliqua. | 928Ut enim{119: }{120:ut}{119: minim veniam}{116:,} quis nostrud | 929exercit{119:a}{120:labore}{119:llamco la}{116:b}oris nisi ut aliquip ex | 930{3:[No Nam}{121:e}{137:et}{121:[+] }{124: }{3: }| 931Lorem i{119:p}{120:dolor}{125:e}{126:l}{119:or sit a}{116:m}et, consectetur | 932adipisi{119:c}{120:magn}{145:a}{128:l}{119:it, sed d}{116:o} eiusmod tempor | 933bla bla{119: }{120:aliqua}{119:dunt }{116: } | 934incidid{119:u}{120:Ut}{119: }{129:ut}{119: labore et}{116: }d{10:ol}ore magna aliqua. | 935Ut enim{119: }{120:enim}{119:inim veniam}{116:,} quis nostrud | 936{2:[No Nam}{130:e}{137:ad}{130:[+] }{132: }{2: }| 937{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 938]] ) 939 940api . nvim_input_mouse ( 'wheel' , 'down' , '' , 0 , 9 , 40 ) 941screen : expect ( [[ 942Lorem ipsum d{10:ol}or sit amet, consectetur | 943adipisicing elit, sed do eiusmod tempor | 944bla bla incididunt^ | 945incidid{116:u}{117:incididunt}{116:re et}{118: }d{10:ol}ore magna aliqua. | 946Ut enim{119: }{120:ut}{119: minim veniam}{116:,} quis nostrud | 947exercit{119:a}{120:labore}{119:llamco la}{116:b}oris nisi ut aliquip ex | 948{3:[No Nam}{121:e}{137:et}{121:[+] }{124: }{3: }| 949incidid{119:u}{120:dol}{134:or}{120:e}{119:labore et}{116: }d{10:ol}ore magna aliqua. | 950Ut enim{119: }{120:magna}{119:nim veniam}{116:,} quis nostrud | 951exercit{119:a}{120:aliqua}{119:llamco la}{116:b}oris nisi {18:ut} aliquip ex | 952ea comm{119:o}{120:Ut}{119: consequat. D}{116:u}is a{18:ut}e irure d{10:ol}or in | 953reprehe{119:n}{120:enim}{119:t in v}{126:ol}{119:upt}{116:a}te v{15:el}it esse cillum | 954{2:[No Nam}{130:e}{137:ad}{130:[+] }{132: }{2: }| 955{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 956]] ) 957 958-- can disable blending for individual attribute. For instance current 959-- selected item. (also tests that `hi Pmenu*` take immediate effect) 960command ( 'hi PMenuSel blend=0' ) 961screen : expect ( [[ 962Lorem ipsum d{10:ol}or sit amet, consectetur | 963adipisicing elit, sed do eiusmod tempor | 964bla bla incididunt^ | 965incidid{138: incididunt }{118: }d{10:ol}ore magna aliqua. | 966Ut enim{119: }{120:ut}{119: minim veniam}{116:,} quis nostrud | 967exercit{119:a}{120:labore}{119:llamco la}{116:b}oris nisi ut aliquip ex | 968{3:[No Nam}{121:e}{137:et}{121:[+] }{124: }{3: }| 969incidid{119:u}{120:dol}{134:or}{120:e}{119:labore et}{116: }d{10:ol}ore magna aliqua. | 970Ut enim{119: }{120:magna}{119:nim veniam}{116:,} quis nostrud | 971exercit{119:a}{120:aliqua}{119:llamco la}{116:b}oris nisi {18:ut} aliquip ex | 972ea comm{119:o}{120:Ut}{119: consequat. D}{116:u}is a{18:ut}e irure d{10:ol}or in | 973reprehe{119:n}{120:enim}{119:t in v}{126:ol}{119:upt}{116:a}te v{15:el}it esse cillum | 974{2:[No Nam}{130:e}{137:ad}{130:[+] }{132: }{2: }| 975{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 976]] ) 977 978feed ( '<c-e>' ) 979screen : expect ( [[ 980Lorem ipsum d{10:ol}or sit amet, consectetur | 981adipisicing elit, sed do eiusmod tempor | 982bla bla ^ | 983incididunt ut labore et d{10:ol}ore magna aliqua. | 984Ut enim ad minim veniam, quis nostrud | 985exercitation ullamco laboris nisi ut aliquip ex | 986{3:[No Name] [+] }| 987incididunt {18:ut} labore et d{10:ol}ore magna aliqua. | 988Ut enim ad minim veniam, quis nostrud | 989exercitation ullamco laboris nisi {18:ut} aliquip ex | 990ea commodo consequat. Duis a{18:ut}e irure d{10:ol}or in | 991reprehenderit in v{10:ol}uptate v{15:el}it esse cillum | 992{2:[No Name] [+] }| 993{5:-- INSERT --} | 994]] ) 995end ) 996 997it ( '256-color (non-RGB)' , function () 998screen . _options . rgb =false 999command ( 'set pumblend=10' ) 1000insert ( [[ 1001Lorem ipsum dolor sit amet, consectetur 1002adipisicing elit, sed do eiusmod tempor 1003incididunt ut labore et dolore magna aliqua. 1004Ut enim ad minim veniam, quis nostrud 1005laborum.]] ) 1006 1007feed ( 'ggOdo<c-x><c-n>' ) 1008screen : expect ( [[ 1009dolor^ | 1010{139:dolor}{140: ipsum dol}or sit amet, consectetur | 1011{141:do}{142:ipisicing eli}t, sed do eiusmod tempor | 1012{141:dolore}{142:dunt ut l}abore et dolore magna aliqua. | 1013Ut enim ad minim veniam, quis nostrud | 1014laborum. | 1015{143:~ }|*7 1016{5:-- Keyword Local completion (^N^P) }{144:match 1 of 3} | 1017]] ) 1018end ) 1019end ) 1020 1021describe ( 'builtin popupmenu' , function () 1022before_each ( clear ) 1023 1024local function with_ext_multigrid ( multigrid , send_mouse_grid ) 1025local screen 1026before_each ( function () 1027screen =Screen . new ( 32 , 20 , { ext_multigrid =multigrid } ) 1028screen : add_extra_attr_ids ( { 1029[ 100 ] ={ foreground =Screen . colors . Yellow , background =Screen . colors . Green } , 1030[ 101 ] ={ foreground =Screen . colors . White , background =Screen . colors . Green } , 1031[ 102 ] ={ foreground =Screen . colors . Brown , bold =true , background =Screen . colors . Plum1 } , 1032[ 103 ] ={ foreground =Screen . colors . DarkCyan , background =Screen . colors . Plum1 } , 1033[ 104 ] ={ foreground =Screen . colors . SlateBlue , background =Screen . colors . Plum1 } , 1034[ 105 ] ={ foreground =Screen . colors . Magenta1 , background =Screen . colors . Plum1 } , 1035[ 106 ] ={ 1036foreground =Screen . colors . Red , 1037italic =true , 1038background =Screen . colors . Gray , 1039strikethrough =true , 1040underline =true , 1041} , 1042[ 107 ] ={ 1043background =Screen . colors . Grey100 , 1044foreground =Screen . colors . Black , 1045italic =true , 1046bold =true , 1047underline =true , 1048strikethrough =true , 1049} , 1050[ 108 ] ={ 1051italic =true , 1052background =Screen . colors . Gray , 1053underline =true , 1054foreground =Screen . colors . Grey100 , 1055} , 1056[ 109 ] ={ 1057foreground =Screen . colors . Yellow , 1058italic =true , 1059bold =true , 1060underline =true , 1061background =Screen . colors . Pink , 1062} , 1063[ 110 ] ={ background =Screen . colors . Grey , foreground =Screen . colors . DarkYellow } , 1064[ 111 ] ={ background =Screen . colors . Plum1 , foreground =Screen . colors . DarkBlue } , 1065[ 112 ] ={ background =Screen . colors . Plum1 , foreground =Screen . colors . DarkGreen } , 1066[ 113 ] ={ background =Screen . colors . Yellow , foreground =Screen . colors . Black } , 1067[ 114 ] ={ background =Screen . colors . Black , blend =100 } , 1068[ 115 ] ={ background =Screen . colors . Black , blend =80 } , 1069[ 116 ] ={ foreground =Screen . colors . Black } , 1070[ 117 ] ={ background =Screen . colors . Grey80 , foreground =Screen . colors . Black } , 1071-- popup non-selected item 1072n ={ background =Screen . colors . Plum1 } , 1073-- popup scrollbar knob 1074c ={ background =Screen . colors . Black } , 1075ks ={ foreground =Screen . colors . Red , background =Screen . colors . Grey } , 1076kn ={ foreground =Screen . colors . Red , background =Screen . colors . Plum1 } , 1077xs ={ foreground =Screen . colors . Black , background =Screen . colors . Grey } , 1078xn ={ foreground =Screen . colors . White , background =Screen . colors . Plum1 } , 1079ms ={ foreground =Screen . colors . Blue , background =Screen . colors . Grey } , 1080mn ={ foreground =Screen . colors . Blue , background =Screen . colors . Plum1 } , 1081ds ={ foreground =Screen . colors . DarkRed , background =Screen . colors . Grey } , 1082dn ={ foreground =Screen . colors . DarkRed , background =Screen . colors . Plum1 } , 1083ums ={ 1084foreground =Screen . colors . Blue , 1085background =Screen . colors . Grey , 1086underline =true , 1087} , 1088umn ={ 1089foreground =Screen . colors . Blue , 1090background =Screen . colors . Plum1 , 1091underline =true , 1092} , 1093uds ={ 1094foreground =Screen . colors . DarkRed , 1095background =Screen . colors . Grey , 1096underline =true , 1097} , 1098udn ={ 1099foreground =Screen . colors . DarkRed , 1100background =Screen . colors . Plum1 , 1101underline =true , 1102} , 1103} ) 1104end ) 1105 1106-- oldtest: Test_pum_position_with_concealed_text() 1107it ( 'position with fully concealed text' , function () 1108screen : try_resize ( 55 , 10 ) 1109exec ( [[ 1110call setline(1, ['CONCEALED foobar', 'CONCEALED foo']) 1111syntax match Hidden /CONCEALED / conceal 1112setlocal conceallevel=3 concealcursor=nvic 1113set completeopt=menu,menuone 1114]] ) 1115feed ( '2GA' ) 1116poke_eventloop () 1117feed ( '<C-X><C-N>' ) 1118if multigrid then 1119screen : expect ( { 1120float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 1121} ) 1122else 1123screen : expect ( [[ 1124foobar | 1125foobar^ | 1126{12:foobar }{1: }| 1127{1:~ }|*6 1128{5:-- Keyword Local completion (^N^P) The only match} | 1129]] ) 1130end 1131end ) 1132 1133-- oldtest: Test_pum_position_with_concealed_match() 1134it ( 'position with concealed text replacement char' , function () 1135screen : try_resize ( 55 , 10 ) 1136exec ( [[ 1137call setline(1, ['XXX foobar', 'XXX foo']) 1138call matchadd('Conceal', 'XXX ', 10, -1, {'conceal': '+'}) 1139setlocal conceallevel=2 concealcursor=nvic 1140set completeopt=menu,menuone 1141]] ) 1142feed ( '2GA' ) 1143poke_eventloop () 1144feed ( '<C-X><C-N>' ) 1145if multigrid then 1146screen : expect ( { 1147float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 1148} ) 1149else 1150screen : expect ( [[ 1151{14:+}foobar | 1152{14:+}foobar^ | 1153{12: foobar }{1: }| 1154{1:~ }|*6 1155{5:-- Keyword Local completion (^N^P) The only match} | 1156]] ) 1157end 1158end ) 1159 1160-- oldtest: Test_pum_position_with_concealed_rl() 1161it ( 'position with concealed text and rightleft' , function () 1162screen : try_resize ( 55 , 10 ) 1163exec ( [[ 1164set rightleft 1165call setline(1, ['CONCEALED foobar', 'CONCEALED foo']) 1166syntax match Hidden /CONCEALED / conceal 1167setlocal conceallevel=3 concealcursor=nvic 1168set completeopt=menu,menuone 1169]] ) 1170feed ( '2GA' ) 1171poke_eventloop () 1172feed ( '<C-X><C-N>' ) 1173if multigrid then 1174screen : expect ( { 1175float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 40 , false , 100 , 1 , 2 , 40 } } , 1176} ) 1177else 1178screen : expect ( [[ 1179raboof| 1180^ raboof| 1181{1: }{12: raboof}| 1182{1: ~}|*6 1183{5:-- Keyword Local completion (^N^P) The only match} | 1184]] ) 1185end 1186end ) 1187 1188-- oldtest: Test_pum_position_with_concealed_wrap() 1189it ( 'position with wrapped concealed text' , function () 1190screen : try_resize ( 20 , 10 ) 1191exec ( [[ 1192call setline(1, ['foobar', 'aaaaaaaaaaaaaaaaaaaa CONCEALED foo']) 1193syntax match Hidden /CONCEALED / conceal 1194setlocal conceallevel=3 concealcursor=nvic 1195set completeopt=menu,menuone 1196]] ) 1197feed ( '2GA' ) 1198poke_eventloop () 1199feed ( '<C-X><C-N>' ) 1200if multigrid then 1201screen : expect ( { 1202float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 3 , 0 , false , 100 , 1 , 3 , 0 } } , 1203} ) 1204else 1205screen : expect ( [[ 1206foobar | 1207aaaaaaaaaaaaaaaaaaaa| 1208foobar^ | 1209{12: foobar }{1: }| 1210{1:~ }|*5 1211{5:-- The only match} | 1212]] ) 1213end 1214end ) 1215 1216it ( 'with preview-window above' , function () 1217feed ( ':ped<CR><c-w>4+' ) 1218feed ( 'iaa bb cc dd ee ff gg hh ii jj<cr>' ) 1219feed ( '<c-x><c-n>' ) 1220if multigrid then 1221screen : expect { 1222grid =[[ 1223## grid 1 1224[4:--------------------------------]|*8 1225{2:[No Name] [Preview][+] }| 1226[2:--------------------------------]|*9 1227{3:[No Name] [+] }| 1228[3:--------------------------------]| 1229## grid 2 1230aa bb cc dd ee ff gg hh ii jj | 1231aa^ | 1232{1:~ }|*7 1233## grid 3 1234{5:-- }{6:match 1 of 10} | 1235## grid 4 1236aa bb cc dd ee ff gg hh ii jj | 1237aa | 1238{1:~ }|*6 1239## grid 5 1240{12:aa }{c: }| 1241{n:bb }{c: }| 1242{n:cc }{c: }| 1243{n:dd }{c: }| 1244{n:ee }{c: }| 1245{n:ff }{c: }| 1246{n:gg }{12: }| 1247{n:hh }{12: }| 1248]] , 1249float_pos ={ [ 5 ] ={ - 1 , 'NW' , 2 , 2 , 0 , false , 100 , 1 , 11 , 0 } } , 1250} 1251else 1252screen : expect ( [[ 1253aa bb cc dd ee ff gg hh ii jj | 1254aa | 1255{1:~ }|*6 1256{2:[No Name] [Preview][+] }| 1257aa bb cc dd ee ff gg hh ii jj | 1258aa^ | 1259{12:aa }{c: }{1: }| 1260{n:bb }{c: }{1: }| 1261{n:cc }{c: }{1: }| 1262{n:dd }{c: }{1: }| 1263{n:ee }{c: }{1: }| 1264{n:ff }{c: }{1: }| 1265{n:gg }{12: }{1: }| 1266{n:hh }{12: }{3: }| 1267{5:-- }{6:match 1 of 10} | 1268]] ) 1269end 1270end ) 1271 1272it ( 'with preview-window below' , function () 1273feed ( ':ped<CR><c-w>4+<c-w>r' ) 1274feed ( 'iaa bb cc dd ee ff gg hh ii jj<cr>' ) 1275feed ( '<c-x><c-n>' ) 1276if multigrid then 1277screen : expect { 1278grid =[[ 1279## grid 1 1280[2:--------------------------------]|*9 1281{3:[No Name] [+] }| 1282[4:--------------------------------]|*8 1283{2:[No Name] [Preview][+] }| 1284[3:--------------------------------]| 1285## grid 2 1286aa bb cc dd ee ff gg hh ii jj | 1287aa^ | 1288{1:~ }|*7 1289## grid 3 1290{5:-- }{6:match 1 of 10} | 1291## grid 4 1292aa bb cc dd ee ff gg hh ii jj | 1293aa | 1294{1:~ }|*6 1295## grid 5 1296{12:aa }{c: }| 1297{n:bb }{c: }| 1298{n:cc }{c: }| 1299{n:dd }{c: }| 1300{n:ee }{c: }| 1301{n:ff }{c: }| 1302{n:gg }{12: }| 1303{n:hh }{12: }| 1304]] , 1305float_pos ={ [ 5 ] ={ - 1 , 'NW' , 2 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 1306} 1307else 1308screen : expect ( [[ 1309aa bb cc dd ee ff gg hh ii jj | 1310aa^ | 1311{12:aa }{c: }{1: }| 1312{n:bb }{c: }{1: }| 1313{n:cc }{c: }{1: }| 1314{n:dd }{c: }{1: }| 1315{n:ee }{c: }{1: }| 1316{n:ff }{c: }{1: }| 1317{n:gg }{12: }{1: }| 1318{n:hh }{12: }{3: }| 1319aa bb cc dd ee ff gg hh ii jj | 1320aa | 1321{1:~ }|*6 1322{2:[No Name] [Preview][+] }| 1323{5:-- }{6:match 1 of 10} | 1324]] ) 1325end 1326end ) 1327 1328it ( 'with preview-window above, tall and inverted' , function () 1329feed ( ':ped<CR><c-w>8+' ) 1330feed ( 'iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>' ) 1331feed ( 'ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>' ) 1332feed ( 'kk<cr>ll<cr>mm<cr>nn<cr>oo<cr>' ) 1333feed ( '<c-x><c-n>' ) 1334if multigrid then 1335screen : expect { 1336grid =[[ 1337## grid 1 1338[4:--------------------------------]|*4 1339{2:[No Name] [Preview][+] }| 1340[2:--------------------------------]|*13 1341{3:[No Name] [+] }| 1342[3:--------------------------------]| 1343## grid 2 1344dd | 1345ee | 1346ff | 1347gg | 1348hh | 1349ii | 1350jj | 1351kk | 1352ll | 1353mm | 1354nn | 1355oo | 1356aa^ | 1357## grid 3 1358{5:-- }{6:match 1 of 15} | 1359## grid 4 1360aa | 1361bb | 1362cc | 1363dd | 1364## grid 5 1365{12:aa }{c: }| 1366{n:bb }{c: }| 1367{n:cc }{c: }| 1368{n:dd }{c: }| 1369{n:ee }{c: }| 1370{n:ff }{c: }| 1371{n:gg }{c: }| 1372{n:hh }{c: }| 1373{n:ii }{c: }| 1374{n:jj }{c: }| 1375{n:kk }{c: }| 1376{n:ll }{12: }| 1377{n:mm }{12: }| 1378]] , 1379float_pos ={ [ 5 ] ={ - 1 , 'SW' , 2 , 12 , 0 , false , 100 , 1 , 4 , 0 } } , 1380} 1381else 1382screen : expect ( [[ 1383aa | 1384bb | 1385cc | 1386dd | 1387{12:aa }{c: }{2:ew][+] }| 1388{n:bb }{c: } | 1389{n:cc }{c: } | 1390{n:dd }{c: } | 1391{n:ee }{c: } | 1392{n:ff }{c: } | 1393{n:gg }{c: } | 1394{n:hh }{c: } | 1395{n:ii }{c: } | 1396{n:jj }{c: } | 1397{n:kk }{c: } | 1398{n:ll }{12: } | 1399{n:mm }{12: } | 1400aa^ | 1401{3:[No Name] [+] }| 1402{5:-- }{6:match 1 of 15} | 1403]] ) 1404end 1405end ) 1406 1407it ( 'with preview-window above, short and inverted' , function () 1408feed ( ':ped<CR><c-w>4+' ) 1409feed ( 'iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>' ) 1410feed ( 'ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>' ) 1411feed ( '<c-x><c-n>' ) 1412if multigrid then 1413screen : expect { 1414grid =[[ 1415## grid 1 1416[4:--------------------------------]|*8 1417{2:[No Name] [Preview][+] }| 1418[2:--------------------------------]|*9 1419{3:[No Name] [+] }| 1420[3:--------------------------------]| 1421## grid 2 1422cc | 1423dd | 1424ee | 1425ff | 1426gg | 1427hh | 1428ii | 1429jj | 1430aa^ | 1431## grid 3 1432{5:-- }{6:match 1 of 10} | 1433## grid 4 1434aa | 1435bb | 1436cc | 1437dd | 1438ee | 1439ff | 1440gg | 1441hh | 1442## grid 5 1443{12:aa }{c: }| 1444{n:bb }{c: }| 1445{n:cc }{c: }| 1446{n:dd }{c: }| 1447{n:ee }{c: }| 1448{n:ff }{c: }| 1449{n:gg }{c: }| 1450{n:hh }{c: }| 1451{n:ii }{12: }| 1452]] , 1453float_pos ={ [ 5 ] ={ - 1 , 'SW' , 2 , 8 , 0 , false , 100 , 1 , 8 , 0 } } , 1454} 1455else 1456screen : expect ( [[ 1457aa | 1458bb | 1459cc | 1460dd | 1461ee | 1462ff | 1463gg | 1464hh | 1465{12:aa }{c: }{2:ew][+] }| 1466{n:bb }{c: } | 1467{n:cc }{c: } | 1468{n:dd }{c: } | 1469{n:ee }{c: } | 1470{n:ff }{c: } | 1471{n:gg }{c: } | 1472{n:hh }{c: } | 1473{n:ii }{12: } | 1474aa^ | 1475{3:[No Name] [+] }| 1476{5:-- }{6:match 1 of 10} | 1477]] ) 1478end 1479end ) 1480 1481it ( 'with preview-window below, inverted' , function () 1482feed ( ':ped<CR><c-w>4+<c-w>r' ) 1483feed ( 'iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>' ) 1484feed ( 'ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>' ) 1485feed ( '<c-x><c-n>' ) 1486if multigrid then 1487screen : expect { 1488grid =[[ 1489## grid 1 1490[2:--------------------------------]|*9 1491{3:[No Name] [+] }| 1492[4:--------------------------------]|*8 1493{2:[No Name] [Preview][+] }| 1494[3:--------------------------------]| 1495## grid 2 1496cc | 1497dd | 1498ee | 1499ff | 1500gg | 1501hh | 1502ii | 1503jj | 1504aa^ | 1505## grid 3 1506{5:-- }{6:match 1 of 10} | 1507## grid 4 1508aa | 1509bb | 1510cc | 1511dd | 1512ee | 1513ff | 1514gg | 1515hh | 1516## grid 5 1517{12:aa }{c: }| 1518{n:bb }{c: }| 1519{n:cc }{c: }| 1520{n:dd }{c: }| 1521{n:ee }{c: }| 1522{n:ff }{c: }| 1523{n:gg }{12: }| 1524{n:hh }{12: }| 1525]] , 1526float_pos ={ [ 5 ] ={ - 1 , 'SW' , 2 , 8 , 0 , false , 100 , 1 , 0 , 0 } } , 1527} 1528else 1529screen : expect ( [[ 1530{12:aa }{c: } | 1531{n:bb }{c: } | 1532{n:cc }{c: } | 1533{n:dd }{c: } | 1534{n:ee }{c: } | 1535{n:ff }{c: } | 1536{n:gg }{12: } | 1537{n:hh }{12: } | 1538aa^ | 1539{3:[No Name] [+] }| 1540aa | 1541bb | 1542cc | 1543dd | 1544ee | 1545ff | 1546gg | 1547hh | 1548{2:[No Name] [Preview][+] }| 1549{5:-- }{6:match 1 of 10} | 1550]] ) 1551end 1552end ) 1553 1554describe ( 'popup and preview window do not overlap' , function () 1555before_each ( function () 1556screen : try_resize ( 53 , 20 ) 1557end ) 1558 1559-- oldtest: Test_popup_and_previewwindow_dump_pedit() 1560it ( 'with :pedit' , function () 1561exec ( [[ 1562set previewheight=9 1563silent! pedit 1564call setline(1, map(repeat(["ab"], 10), "v:val .. v:key")) 1565exec "norm! G\<C-E>\<C-E>" 1566]] ) 1567feed ( 'o' ) 1568n . poke_eventloop () 1569feed ( '<C-X><C-N>' ) 1570if multigrid then 1571screen : expect ( { 1572grid =[[ 1573## grid 1 1574[4:-----------------------------------------------------]|*9 1575{2:[No Name] [Preview][+] }| 1576[2:-----------------------------------------------------]|*8 1577{3:[No Name] [+] }| 1578[3:-----------------------------------------------------]| 1579## grid 2 1580ab4 | 1581ab5 | 1582ab6 | 1583ab7 | 1584ab8 | 1585ab9 | 1586ab0^ | 1587{1:~ }| 1588## grid 3 1589{5:-- Keyword Local completion (^N^P) }{6:match 1 of 10} | 1590## grid 4 1591ab0 | 1592ab1 | 1593ab2 | 1594ab3 | 1595ab4 | 1596ab5 | 1597ab6 | 1598ab7 | 1599ab8 | 1600## grid 5 1601{12:ab0 }{c: }| 1602{n:ab1 }{c: }| 1603{n:ab2 }{c: }| 1604{n:ab3 }{c: }| 1605{n:ab4 }{12: }| 1606{n:ab5 }{12: }| 1607{n:ab6 }{12: }| 1608]] , 1609float_pos ={ [ 5 ] ={ - 1 , 'SW' , 2 , 6 , 0 , false , 100 , 1 , 9 , 0 } } , 1610} ) 1611else 1612screen : expect ( [[ 1613ab0 | 1614ab1 | 1615ab2 | 1616ab3 | 1617ab4 | 1618ab5 | 1619ab6 | 1620ab7 | 1621ab8 | 1622{12:ab0 }{c: }{2:ew][+] }| 1623{n:ab1 }{c: } | 1624{n:ab2 }{c: } | 1625{n:ab3 }{c: } | 1626{n:ab4 }{12: } | 1627{n:ab5 }{12: } | 1628{n:ab6 }{12: } | 1629ab0^ | 1630{1:~ }| 1631{3:[No Name] [+] }| 1632{5:-- Keyword Local completion (^N^P) }{6:match 1 of 10} | 1633]] ) 1634end 1635end ) 1636 1637-- oldtest: Test_popup_and_previewwindow_dump_pbuffer() 1638it ( 'with :pbuffer' , function () 1639exec ( [[ 1640set previewheight=9 1641silent! pbuffer 1642call setline(1, map(repeat(["ab"], 10), "v:val .. v:key")) 1643exec "norm! G\<C-E>\<C-E>\<C-E>" 1644]] ) 1645feed ( 'o' ) 1646n . poke_eventloop () 1647feed ( '<C-X><C-N>' ) 1648if multigrid then 1649screen : expect ( { 1650grid =[[ 1651## grid 1 1652[4:-----------------------------------------------------]|*9 1653{2:[No Name] [Preview][+] }| 1654[2:-----------------------------------------------------]|*8 1655{3:[No Name] [+] }| 1656[3:-----------------------------------------------------]| 1657## grid 2 1658ab5 | 1659ab6 | 1660ab7 | 1661ab8 | 1662ab9 | 1663ab0^ | 1664{1:~ }|*2 1665## grid 3 1666{5:-- Keyword Local completion (^N^P) }{6:match 1 of 10} | 1667## grid 4 1668ab0 | 1669ab1 | 1670ab2 | 1671ab3 | 1672ab4 | 1673ab5 | 1674ab6 | 1675ab7 | 1676ab8 | 1677## grid 5 1678{12:ab0 }{c: }| 1679{n:ab1 }{c: }| 1680{n:ab2 }{c: }| 1681{n:ab3 }{12: }| 1682{n:ab4 }{12: }| 1683{n:ab5 }{12: }| 1684]] , 1685float_pos ={ [ 5 ] ={ - 1 , 'SW' , 2 , 5 , 0 , false , 100 , 1 , 9 , 0 } } , 1686} ) 1687else 1688screen : expect ( [[ 1689ab0 | 1690ab1 | 1691ab2 | 1692ab3 | 1693ab4 | 1694ab5 | 1695ab6 | 1696ab7 | 1697ab8 | 1698{12:ab0 }{c: }{2:ew][+] }| 1699{n:ab1 }{c: } | 1700{n:ab2 }{c: } | 1701{n:ab3 }{12: } | 1702{n:ab4 }{12: } | 1703{n:ab5 }{12: } | 1704ab0^ | 1705{1:~ }|*2 1706{3:[No Name] [+] }| 1707{5:-- Keyword Local completion (^N^P) }{6:match 1 of 10} | 1708]] ) 1709end 1710end ) 1711end ) 1712 1713-- oldtest: Test_pum_with_preview_win() 1714it ( 'preview window opened during completion' , function () 1715exec ( [[ 1716funct Omni_test(findstart, base) 1717if a:findstart 1718return col(".") - 1 1719endif 1720return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}] 1721endfunc 1722set omnifunc=Omni_test 1723set completeopt-=popup completeopt+=longest,preview 1724]] ) 1725feed ( 'Gi<C-X><C-O>' ) 1726if multigrid then 1727screen : expect ( { 1728grid =[[ 1729## grid 1 1730[2:--------------------------------]|*19 1731[3:--------------------------------]| 1732## grid 2 1733^ | 1734{1:~ }|*18 1735## grid 3 1736{5:-- }{19:Back at original} | 1737## grid 4 1738{n:one }| 1739{n:two }| 1740{n:three }| 1741]] , 1742float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 1743} ) 1744else 1745screen : expect ( [[ 1746^ | 1747{n:one }{1: }| 1748{n:two }{1: }| 1749{n:three }{1: }| 1750{1:~ }|*15 1751{5:-- }{19:Back at original} | 1752]] ) 1753end 1754feed ( '<C-N>' ) 1755if multigrid then 1756screen : expect ( { 1757grid =[[ 1758## grid 1 1759[5:--------------------------------]|*3 1760{2:[Scratch] [Preview][-] }| 1761[2:--------------------------------]|*14 1762{3:[No Name] [+] }| 1763[3:--------------------------------]| 1764## grid 2 1765one^ | 1766{1:~ }|*13 1767## grid 3 1768{5:-- }{6:match 1 of 3} | 1769## grid 4 1770{12:one }| 1771{n:two }| 1772{n:three }| 1773## grid 5 17741info | 1775{1:~ }|*2 1776]] , 1777float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 5 , 0 } } , 1778} ) 1779else 1780screen : expect ( [[ 17811info | 1782{1:~ }|*2 1783{2:[Scratch] [Preview][-] }| 1784one^ | 1785{12:one }{1: }| 1786{n:two }{1: }| 1787{n:three }{1: }| 1788{1:~ }|*10 1789{3:[No Name] [+] }| 1790{5:-- }{6:match 1 of 3} | 1791]] ) 1792end 1793end ) 1794 1795-- oldtest: Test_scrollbar_on_wide_char() 1796it ( 'scrollbar overwrites half of double-width char below properly' , function () 1797screen : try_resize ( 32 , 10 ) 1798exec ( [[ 1799call setline(1, ['a', ' 啊啊啊', 1800\ ' 哦哦哦', 1801\ ' 呃呃呃']) 1802call setline(5, range(10)->map({i, v -> 'aa' .. v .. 'bb'})) 1803]] ) 1804feed ( 'A<C-X><C-N>' ) 1805if multigrid then 1806screen : expect ( { 1807grid =[[ 1808## grid 1 1809[2:--------------------------------]|*9 1810[3:--------------------------------]| 1811## grid 2 1812aa0bb^ | 1813啊啊啊 | 1814哦哦哦 | 1815呃呃呃 | 1816aa0bb | 1817aa1bb | 1818aa2bb | 1819aa3bb | 1820aa4bb | 1821## grid 3 1822{5:-- }{6:match 1 of 10} | 1823## grid 4 1824{12:aa0bb }{c: }| 1825{n:aa1bb }{c: }| 1826{n:aa2bb }{c: }| 1827{n:aa3bb }{c: }| 1828{n:aa4bb }{c: }| 1829{n:aa5bb }{c: }| 1830{n:aa6bb }{12: }| 1831{n:aa7bb }{12: }| 1832]] , 1833float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 1834} ) 1835else 1836screen : expect ( [[ 1837aa0bb^ | 1838{12:aa0bb }{c: }啊 | 1839{n:aa1bb }{c: } 哦 | 1840{n:aa2bb }{c: }呃呃 | 1841{n:aa3bb }{c: } | 1842{n:aa4bb }{c: } | 1843{n:aa5bb }{c: } | 1844{n:aa6bb }{12: } | 1845{n:aa7bb }{12: } | 1846{5:-- }{6:match 1 of 10} | 1847]] ) 1848end 1849end ) 1850 1851describe ( 'completeopt=popup shows preview in floatwin' , function () 1852before_each ( function () 1853--row must > 10 1854screen : try_resize ( 40 , 11 ) 1855exec ( [[ 1856let g:list = [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "looooooooooooooong"}] 1857let g:bufnrs = [] 1858let g:reduce_info_height = 0 1859funct Omni_test(findstart, base) 1860if a:findstart 1861return col(".") - 1 1862endif 1863return g:list 1864endfunc 1865set omnifunc=Omni_test 1866set completeopt=menu,popup 1867funct Set_info() 1868let comp_info = complete_info() 1869if get(comp_info, 'preview_bufnr', 0) > 0 1870call add(g:bufnrs, comp_info['preview_bufnr']) 1871endif 1872if comp_info['selected'] == 2 1873call nvim__complete_set(comp_info['selected'], {"info": "3info"}) 1874endif 1875endfunc 1876funct TsHl() 1877let comp_info = complete_info(['selected']) 1878if comp_info['selected'] == 0 1879let windata = nvim__complete_set(comp_info['selected'], {"info": "```lua\nfunction test()\n print('foo')\nend\n```"}) 1880call v:lua.vim.treesitter.start(windata['bufnr'], 'markdown') 1881if g:reduce_info_height > 0 1882let h = v:lua.vim.api.nvim_win_text_height(windata['winid'], {}).all 1883if h > 3 1884call v:lua.vim.api.nvim_win_set_height(windata['winid'], h - 3) 1885endif 1886endif 1887endif 1888endfunc 1889augroup Group 1890au! 1891autocmd CompleteChanged * :call Set_info() 1892augroup END 1893funct TestTs() 1894autocmd! Group 1895autocmd CompleteChanged * call TsHl() 1896endfunc 1897funct Append_multipe() 1898call extend(g:list, [#{word: "for .. ipairs", info: "```lua\nfor index, value in ipairs(t) do\n\t\nend\n```"}]) 1899endfunc 1900]] ) 1901end ) 1902 1903it ( 'pum popup preview' , function () 1904feed ( 'Gi<C-x><C-o>' ) 1905--floating preview in right 1906if multigrid then 1907screen : expect ( { 1908grid =[[ 1909## grid 1 1910[2:----------------------------------------]|*10 1911[3:----------------------------------------]| 1912## grid 2 1913one^ | 1914{1:~ }|*9 1915## grid 3 1916{5:-- }{6:match 1 of 3} | 1917## grid 4 1918{n:1info}| 1919## grid 5 1920{12:one }| 1921{n:two }| 1922{n:looooooooooooooong }| 1923]] , 1924win_pos ={ [ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 1925float_pos ={ 1926[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 2 , 1 , 0 } , 1927[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 19 , true , 50 , 1 , 1 , 19 } , 1928} , 1929} ) 1930else 1931screen : expect ( [[ 1932one^ | 1933{12:one }{n:1info}{1: }| 1934{n:two }{1: }| 1935{n:looooooooooooooong }{1: }| 1936{1:~ }|*6 1937{5:-- }{6:match 1 of 3} | 1938]] ) 1939end 1940 1941-- delete one character make the pum width smaller than before 1942-- info window position should be adjusted when popupmenu width changed 1943feed ( '<BS>' ) 1944if multigrid then 1945screen : expect ( { 1946grid =[[ 1947## grid 1 1948[2:----------------------------------------]|*10 1949[3:----------------------------------------]| 1950## grid 2 1951on^ | 1952{1:~ }|*9 1953## grid 3 1954{5:-- }{6:match 1 of 3} | 1955## grid 4 1956{n:1info}| 1957## grid 5 1958{12:one }| 1959]] , 1960win_pos ={ [ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 1961float_pos ={ 1962[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 2 , 1 , 0 } , 1963[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 15 , true , 50 , 1 , 1 , 15 } , 1964} , 1965} ) 1966else 1967screen : expect ( [[ 1968on^ | 1969{12:one }{n:1info}{1: }| 1970{1:~ }|*8 1971{5:-- }{6:match 1 of 3} | 1972]] ) 1973end 1974 1975-- when back to original the preview float should be closed. 1976feed ( '<C-P>' ) 1977if multigrid then 1978screen : expect ( { 1979grid =[[ 1980## grid 1 1981[2:----------------------------------------]|*10 1982[3:----------------------------------------]| 1983## grid 2 1984on^ | 1985{1:~ }|*9 1986## grid 3 1987{5:-- }{19:Back at original} | 1988## grid 4 (hidden) 1989{n:1info}| 1990## grid 5 1991{n:one }| 1992]] , 1993win_pos ={ [ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 1994float_pos ={ [ 5 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 1995win_viewport ={ 1996[ 2 ] ={ 1997win =1000 , 1998topline =0 , 1999botline =2 , 2000curline =0 , 2001curcol =2 , 2002linecount =1 , 2003sum_scroll_delta =0 , 2004} , 2005[ 4 ] ={ 2006win =1001 , 2007topline =0 , 2008botline =1 , 2009curline =0 , 2010curcol =0 , 2011linecount =1 , 2012sum_scroll_delta =0 , 2013} , 2014} , 2015win_viewport_margins ={ 2016[ 2 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1000 } , 2017[ 4 ] ={ bottom =0 , left =0 , right =0 , top =0 , win =1001 } , 2018} , 2019} ) 2020else 2021screen : expect ( [[ 2022on^ | 2023{n:one }{1: }| 2024{1:~ }|*8 2025{5:-- }{19:Back at original} | 2026]] ) 2027end 2028feed ( '<C-E><ESC>' ) 2029end ) 2030 2031it ( 'nvim__set_complete' , function () 2032feed ( 'S<C-X><C-O><C-N><C-N>' ) 2033if multigrid then 2034screen : expect ( { 2035grid =[[ 2036## grid 1 2037[2:----------------------------------------]|*10 2038[3:----------------------------------------]| 2039## grid 2 2040looooooooooooooong^ | 2041{1:~ }|*9 2042## grid 3 2043{5:-- }{6:match 3 of 3} | 2044## grid 4 2045{n:3info}| 2046## grid 5 2047{n:one }| 2048{n:two }| 2049{12:looooooooooooooong }| 2050]] , 2051win_pos ={ [ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 2052float_pos ={ 2053[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 2 , 1 , 0 } , 2054[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 19 , true , 50 , 1 , 1 , 19 } , 2055} , 2056} ) 2057else 2058screen : expect ( [[ 2059looooooooooooooong^ | 2060{n:one 3info}{1: }| 2061{n:two }{1: }| 2062{12:looooooooooooooong }{1: }| 2063{1:~ }|*6 2064{5:-- }{6:match 3 of 3} | 2065]] ) 2066end 2067feed ( '<C-E><ESC>' ) 2068end ) 2069 2070it ( 'popup preview placed to left' , function () 2071insert (( 'test' ): rep ( 5 )) 2072feed ( 'i<C-x><C-o>' ) 2073if multigrid then 2074screen : expect ( { 2075grid =[[ 2076## grid 1 2077[2:----------------------------------------]|*10 2078[3:----------------------------------------]| 2079## grid 2 2080testtesttesttesttesone^t | 2081{1:~ }|*9 2082## grid 3 2083{5:-- }{6:match 1 of 3} | 2084## grid 4 2085{n:1info}| 2086## grid 5 2087{12: one }| 2088{n: two }| 2089{n: looooooooooooooong }| 2090]] , 2091win_pos ={ [ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 2092float_pos ={ 2093[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 18 , false , 100 , 2 , 1 , 18 } , 2094[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 13 , true , 50 , 1 , 1 , 13 } , 2095} , 2096} ) 2097else 2098screen : expect ( [[ 2099testtesttesttesttesone^t | 2100{1:~ }{n:1info}{12: one }{1: }| 2101{1:~ }{n: two }{1: }| 2102{1:~ }{n: looooooooooooooong }{1: }| 2103{1:~ }|*6 2104{5:-- }{6:match 1 of 3} | 2105]] ) 2106end 2107feed ( '<C-E><Esc>' ) 2108end ) 2109 2110it ( 'works when scroll with treesitter highlight' , function () 2111command ( 'call TestTs()' ) 2112feed ( 'S<C-x><C-o>' ) 2113if multigrid then 2114screen : expect ( { 2115grid =[[ 2116## grid 1 2117[2:----------------------------------------]|*10 2118[3:----------------------------------------]| 2119## grid 2 2120one^ | 2121{1:~ }|*9 2122## grid 3 2123{5:-- }{6:match 1 of 3} | 2124## grid 4 2125{mn:```}{102:lua}{n: }| 2126{102:function}{mn: }{103:test}{104:()}| 2127{mn: }{104:print(}{105:'foo'}{104:)}{n: }| 2128{102:end}{n: }| 2129{mn:```}{n: }| 2130## grid 5 2131{12:one }| 2132{n:two }| 2133{n:looooooooooooooong }| 2134]] , 2135win_pos ={ [ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 2136float_pos ={ 2137[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 2 , 1 , 0 } , 2138[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 19 , true , 50 , 1 , 1 , 19 } , 2139} , 2140} ) 2141else 2142screen : expect ( [[ 2143one^ | 2144{12:one }{mn:```}{102:lua}{n: }{1: }| 2145{n:two }{102:function}{mn: }{103:test}{104:()}{1: }| 2146{n:looooooooooooooong }{mn: }{104:print(}{105:'foo'}{104:)}{n: }{1: }| 2147{1:~ }{102:end}{n: }{1: }| 2148{1:~ }{mn:```}{n: }{1: }| 2149{1:~ }|*4 2150{5:-- }{6:match 1 of 3} | 2151]] ) 2152end 2153end ) 2154 2155it ( 'info window aligns with pum when above cursor' , function () 2156command ( 'let g:reduce_info_height=1 | call TestTs()' ) 2157feed ( '<C-E><ESC>18o<Esc>i<C-x><C-O>' ) 2158if multigrid then 2159screen : expect ( { 2160grid =[[ 2161## grid 1 2162[2:----------------------------------------]|*10 2163[3:----------------------------------------]| 2164## grid 2 2165|*9 2166one^ | 2167## grid 3 2168{5:-- }{6:match 1 of 3} | 2169## grid 4 2170{mn:```}{102:lua}{n: }| 2171{102:function}{mn: }{103:test}{104:()}| 2172## grid 5 2173{12:one }| 2174{n:two }| 2175{n:looooooooooooooong }| 2176]] , 2177win_pos ={ 2178[ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =40 , win =1000 } , 2179} , 2180float_pos ={ 2181[ 5 ] ={ - 1 , 'SW' , 2 , 9 , 0 , false , 100 , 2 , 6 , 0 } , 2182[ 4 ] ={ 1001 , 'NW' , 1 , 6 , 19 , true , 50 , 1 , 6 , 19 } , 2183} , 2184} ) 2185else 2186screen : expect ( [[ 2187|*6 2188{12:one }{mn:```}{102:lua}{n: } | 2189{n:two }{102:function}{mn: }{103:test}{104:()} | 2190{n:looooooooooooooong } | 2191one^ | 2192{5:-- }{6:match 1 of 3} | 2193]] ) 2194end 2195end ) 2196 2197it ( 'avoid modified original info text' , function () 2198command ( 'call Append_multipe()' ) 2199feed ( 'S<C-x><C-o><C-P><C-P>' ) 2200if multigrid then 2201screen : expect ( { 2202grid =[[ 2203## grid 1 2204[2:----------------------------------------]|*10 2205[3:----------------------------------------]| 2206## grid 2 2207for .. ipairs^ | 2208{1:~ }|*9 2209## grid 3 2210{5:-- }{6:match 1 of 4} | 2211## grid 4 2212{n:one }| 2213{n:two }| 2214{n:looooooooooooooong }| 2215{12:for .. ipairs }| 2216## grid 5 2217{n:```lua }| 2218{n:for index, value in }| 2219{n:ipairs(t) do }| 2220{n: }| 2221{n:end }| 2222{n:``` }| 2223]] , 2224win_pos ={ [ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =40 , win =1000 } } , 2225float_pos ={ 2226[ 5 ] ={ 1001 , 'NW' , 1 , 1 , 19 , true , 50 , 1 , 1 , 19 } , 2227[ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 2 , 1 , 0 } , 2228} , 2229} ) 2230else 2231screen : expect ( [[ 2232for .. ipairs^ | 2233{n:one ```lua }{1: }| 2234{n:two for index, value in }{1: }| 2235{n:looooooooooooooong ipairs(t) do }{1: }| 2236{12:for .. ipairs }{n: }{1: }| 2237{1:~ }{n:end }{1: }| 2238{1:~ }{n:``` }{1: }| 2239{1:~ }|*3 2240{5:-- }{6:match 1 of 4} | 2241]] ) 2242end 2243 2244feed ( '<C-N><C-N><C-N><C-N><C-N>' ) 2245if not multigrid then 2246screen : expect_unchanged () 2247end 2248feed ( '<C-E><ESC>' ) 2249end ) 2250 2251it ( 'popup info window reuses bufnr' , function () 2252feed ( 'S<C-x><C-o><C-N>' ) 2253eq ( 1 , n . eval ( [[len(uniq(copy(g:bufnrs))) == 1]] )) 2254end ) 2255 2256it ( 'handles tabs and "linebreak" in info width calculation' , function () 2257screen : try_resize ( 50 , 11 ) 2258command ( [[ 2259set linebreak 2260set cot+=menuone 2261let g:list = [#{word: 'class', info: "\tClassName() = default;"}] 2262]] ) 2263feed ( 'S<C-x><C-o>' ) 2264local info =fn . complete_info () 2265eq ( 30 , api . nvim_win_get_width ( info . preview_winid )) 2266feed ( '<C-N><C-P>' ) 2267info =fn . complete_info () 2268eq ( 30 , api . nvim_win_get_width ( info . preview_winid )) 2269feed ( '<ESC>' ) 2270exec ( [[ 2271setlocal tabstop=1 2272autocmd ModeChanged *:i ++once call complete(1, [#{word: 'a'}]) 2273\| call nvim__complete_set(0, #{info: "\tfloob\tfloob"}) 2274]] ) 2275feed ( 'i' ) 2276info =fn . complete_info () 2277eq ( 21 , api . nvim_win_get_width ( info . preview_winid )) 2278if not multigrid then 2279screen : expect ( [[ 2280a^s | 2281{12:a }{n: floob floob}{1: }| 2282{1:~ }|*8 2283{5:-- INSERT --} | 2284]] ) 2285end 2286end ) 2287 2288it ( 'hide info window when insufficient space' , function () 2289screen : try_resize ( 12 , 11 ) 2290feed ( 'S<C-x><C-o>' ) 2291local info =fn . complete_info () 2292eq ( true , api . nvim_win_get_config ( info . preview_winid ). hide ) 2293end ) 2294 2295it ( 'enables wrap to avoid info text truncation' , function () 2296screen : try_resize ( 50 , 11 ) 2297command ( [[ 2298set nowrap 2299set cot+=menuone 2300let g:list = [#{word: 'class', info: repeat('+', 60)}] 2301]] ) 2302feed ( 'S<C-x><C-o>' ) 2303local info =fn . complete_info () 2304eq ( 2 , api . nvim_win_get_config ( info . preview_winid ). height ) 2305end ) 2306end ) 2307 2308it ( 'with vsplits' , function () 2309screen : try_resize ( 32 , 8 ) 2310insert ( 'aaa aab aac\n' ) 2311feed ( ':vsplit<cr>' ) 2312if multigrid then 2313screen : expect ( [[ 2314## grid 1 2315[4:--------------------]│[2:-----------]|*6 2316{3:[No Name] [+] }{2:<Name] [+] }| 2317[3:--------------------------------]| 2318## grid 2 2319aaa aab aac| 2320| 2321{1:~ }|*4 2322## grid 3 2323:vsplit | 2324## grid 4 2325aaa aab aac | 2326^ | 2327{1:~ }|*4 2328]] ) 2329else 2330screen : expect ( [[ 2331aaa aab aac │aaa aab aac| 2332^ │ | 2333{1:~ }│{1:~ }|*4 2334{3:[No Name] [+] }{2:<Name] [+] }| 2335:vsplit | 2336]] ) 2337end 2338 2339feed ( 'ibbb a<c-x><c-n>' ) 2340if multigrid then 2341screen : expect { 2342grid =[[ 2343## grid 1 2344[4:--------------------]│[2:-----------]|*6 2345{3:[No Name] [+] }{2:<Name] [+] }| 2346[3:--------------------------------]| 2347## grid 2 2348aaa aab aac| 2349bbb aaa | 2350{1:~ }|*4 2351## grid 3 2352{5:-- }{6:match 1 of 3} | 2353## grid 4 2354aaa aab aac | 2355bbb aaa^ | 2356{1:~ }|*4 2357## grid 5 2358{12: aaa }| 2359{n: aab }| 2360{n: aac }| 2361]] , 2362float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 2 , 3 , false , 100 , 1 , 2 , 3 } } , 2363} 2364else 2365screen : expect ( [[ 2366aaa aab aac │aaa aab aac| 2367bbb aaa^ │bbb aaa | 2368{1:~ }{12: aaa }{1: }│{1:~ }| 2369{1:~ }{n: aab }{1: }│{1:~ }| 2370{1:~ }{n: aac }{1: }│{1:~ }| 2371{1:~ }│{1:~ }| 2372{3:[No Name] [+] }{2:<Name] [+] }| 2373{5:-- }{6:match 1 of 3} | 2374]] ) 2375end 2376 2377feed ( '<esc><c-w><c-w>oc a<c-x><c-n>' ) 2378if multigrid then 2379screen : expect { 2380grid =[[ 2381## grid 1 2382[4:-----------]│[2:--------------------]|*6 2383{2:<Name] [+] }{3:[No Name] [+] }| 2384[3:--------------------------------]| 2385## grid 2 2386aaa aab aac | 2387bbb aaa | 2388c aaa^ | 2389{1:~ }|*3 2390## grid 3 2391{5:-- }{6:match 1 of 3} | 2392## grid 4 2393aaa aab aac| 2394bbb aaa | 2395c aaa | 2396{1:~ }|*3 2397## grid 5 2398{12: aaa }| 2399{n: aab }| 2400{n: aac }| 2401]] , 2402float_pos ={ [ 5 ] ={ - 1 , 'NW' , 2 , 3 , 1 , false , 100 , 1 , 3 , 13 } } , 2403} 2404else 2405screen : expect ( [[ 2406aaa aab aac│aaa aab aac | 2407bbb aaa │bbb aaa | 2408c aaa │c aaa^ | 2409{1:~ }│{1:~}{12: aaa }{1: }| 2410{1:~ }│{1:~}{n: aab }{1: }| 2411{1:~ }│{1:~}{n: aac }{1: }| 2412{2:<Name] [+] }{3:[No Name] [+] }| 2413{5:-- }{6:match 1 of 3} | 2414]] ) 2415end 2416 2417feed ( 'bcdef ccc a<c-x><c-n>' ) 2418if multigrid then 2419screen : expect { 2420grid =[[ 2421## grid 1 2422[4:-----------]│[2:--------------------]|*6 2423{2:<Name] [+] }{3:[No Name] [+] }| 2424[3:--------------------------------]| 2425## grid 2 2426aaa aab aac | 2427bbb aaa | 2428c aaabcdef ccc aaa^ | 2429{1:~ }|*3 2430## grid 3 2431{5:-- }{6:match 1 of 4} | 2432## grid 4 2433aaa aab aac| 2434bbb aaa | 2435c aaabcdef | 2436ccc aaa | 2437{1:~ }|*2 2438## grid 5 2439{12: aaa }| 2440{n: aab }| 2441{n: aac }| 2442{n: aaabcdef }| 2443]] , 2444float_pos ={ [ 5 ] ={ - 1 , 'NW' , 2 , 3 , 3 , false , 100 , 1 , 3 , 15 } } , 2445} 2446else 2447screen : expect ( [[ 2448aaa aab aac│aaa aab aac | 2449bbb aaa │bbb aaa | 2450c aaabcdef │c aaabcdef ccc aaa^ | 2451ccc aaa │{1:~ }{12: aaa }| 2452{1:~ }│{1:~ }{n: aab }| 2453{1:~ }│{1:~ }{n: aac }| 2454{2:<Name] [+] }{3:[No}{n: aaabcdef }| 2455{5:-- }{6:match 1 of 4} | 2456]] ) 2457end 2458 2459feed ( '\n<c-x><c-n>' ) 2460if multigrid then 2461screen : expect { 2462grid =[[ 2463## grid 1 2464[4:-----------]│[2:--------------------]|*6 2465{2:<Name] [+] }{3:[No Name] [+] }| 2466[3:--------------------------------]| 2467## grid 2 2468aaa aab aac | 2469bbb aaa | 2470c aaabcdef ccc aaa | 2471aaa^ | 2472{1:~ }|*2 2473## grid 3 2474{5:-- }{6:match 1 of 6} | 2475## grid 4 2476aaa aab aac| 2477bbb aaa | 2478c aaabcdef | 2479ccc aaa | 2480aaa | 2481{1:~ }| 2482## grid 5 2483{12: aaa }{c: }| 2484{n: aab }{12: }| 2485{n: aac }{12: }| 2486]] , 2487float_pos ={ [ 5 ] ={ - 1 , 'NW' , 2 , 4 , - 1 , false , 100 , 1 , 4 , 11 } } , 2488} 2489else 2490screen : expect ( [[ 2491aaa aab aac│aaa aab aac | 2492bbb aaa │bbb aaa | 2493c aaabcdef │c aaabcdef ccc aaa | 2494ccc aaa │aaa^ | 2495aaa {12: aaa }{c: }{1: }| 2496{1:~ }{n: aab }{12: }{1: }| 2497{2:<Name] [+] }{n: aac }{12: }{3: }| 2498{5:-- }{6:match 1 of 6} | 2499]] ) 2500end 2501end ) 2502 2503it ( 'with split and scroll' , function () 2504screen : try_resize ( 60 , 14 ) 2505command ( 'split' ) 2506command ( 'set completeopt+=noinsert' ) 2507command ( 'set mouse=a' ) 2508insert ( [[ 2509Lorem ipsum dolor sit amet, consectetur 2510adipisicing elit, sed do eiusmod tempor 2511incididunt ut labore et dolore magna aliqua. 2512Ut enim ad minim veniam, quis nostrud 2513exercitation ullamco laboris nisi ut aliquip ex 2514ea commodo consequat. Duis aute irure dolor in 2515reprehenderit in voluptate velit esse cillum 2516dolore eu fugiat nulla pariatur. Excepteur sint 2517occaecat cupidatat non proident, sunt in culpa 2518qui officia deserunt mollit anim id est 2519laborum. 2520. 2521]] ) 2522 2523if multigrid then 2524screen : expect ( [[ 2525## grid 1 2526[4:------------------------------------------------------------]|*6 2527{3:[No Name] [+] }| 2528[2:------------------------------------------------------------]|*5 2529{2:[No Name] [+] }| 2530[3:------------------------------------------------------------]| 2531## grid 2 2532Lorem ipsum dolor sit amet, consectetur | 2533adipisicing elit, sed do eiusmod tempor | 2534incididunt ut labore et dolore magna aliqua. | 2535Ut enim ad minim veniam, quis nostrud | 2536exercitation ullamco laboris nisi ut aliquip ex | 2537## grid 3 2538| 2539## grid 4 2540dolore eu fugiat nulla pariatur. Excepteur sint | 2541occaecat cupidatat non proident, sunt in culpa | 2542qui officia deserunt mollit anim id est | 2543laborum. | 2544. | 2545^ | 2546]] ) 2547else 2548screen : expect ( [[ 2549dolore eu fugiat nulla pariatur. Excepteur sint | 2550occaecat cupidatat non proident, sunt in culpa | 2551qui officia deserunt mollit anim id est | 2552laborum. | 2553. | 2554^ | 2555{3:[No Name] [+] }| 2556Lorem ipsum dolor sit amet, consectetur | 2557adipisicing elit, sed do eiusmod tempor | 2558incididunt ut labore et dolore magna aliqua. | 2559Ut enim ad minim veniam, quis nostrud | 2560exercitation ullamco laboris nisi ut aliquip ex | 2561{2:[No Name] [+] }| 2562| 2563]] ) 2564end 2565 2566feed ( 'ggOEst <c-x><c-p>' ) 2567if multigrid then 2568screen : expect ( { 2569grid =[[ 2570## grid 1 2571[4:------------------------------------------------------------]|*6 2572{3:[No Name] [+] }| 2573[2:------------------------------------------------------------]|*5 2574{2:[No Name] [+] }| 2575[3:------------------------------------------------------------]| 2576## grid 2 2577Est | 2578Lorem ipsum dolor sit amet, consectetur | 2579adipisicing elit, sed do eiusmod tempor | 2580incididunt ut labore et dolore magna aliqua. | 2581Ut enim ad minim veniam, quis nostrud | 2582## grid 3 2583{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2584## grid 4 2585Est ^ | 2586Lorem ipsum dolor sit amet, consectetur | 2587adipisicing elit, sed do eiusmod tempor | 2588incididunt ut labore et dolore magna aliqua. | 2589Ut enim ad minim veniam, quis nostrud | 2590exercitation ullamco laboris nisi ut aliquip ex | 2591## grid 5 2592{n: sunt }{12: }| 2593{n: in }{12: }| 2594{n: culpa }{12: }| 2595{n: qui }{12: }| 2596{n: officia }{12: }| 2597{n: deserunt }{12: }| 2598{n: mollit }{12: }| 2599{n: anim }{12: }| 2600{n: id }{12: }| 2601{n: est }{12: }| 2602{n: laborum }{c: }| 2603{12: Est }{c: }| 2604]] , 2605float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 3 , false , 100 , 1 , 1 , 3 } } , 2606} ) 2607else 2608screen : expect ( [[ 2609Est ^ | 2610L{n: sunt }{12: }sit amet, consectetur | 2611a{n: in }{12: }sed do eiusmod tempor | 2612i{n: culpa }{12: }re et dolore magna aliqua. | 2613U{n: qui }{12: }eniam, quis nostrud | 2614e{n: officia }{12: }co laboris nisi ut aliquip ex | 2615{3:[No}{n: deserunt }{12: }{3: }| 2616Est{n: mollit }{12: } | 2617L{n: anim }{12: }sit amet, consectetur | 2618a{n: id }{12: }sed do eiusmod tempor | 2619i{n: est }{12: }re et dolore magna aliqua. | 2620U{n: laborum }{c: }eniam, quis nostrud | 2621{2:[No}{12: Est }{c: }{2: }| 2622{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2623]] ) 2624end 2625 2626if send_mouse_grid then 2627api . nvim_input_mouse ( 'wheel' , 'down' , '' , 2 , 9 , 33 ) 2628else 2629api . nvim_input_mouse ( 'wheel' , 'down' , '' , 0 , 9 , 40 ) 2630end 2631if multigrid then 2632screen : expect ( { 2633grid =[[ 2634## grid 1 2635[4:------------------------------------------------------------]|*6 2636{3:[No Name] [+] }| 2637[2:------------------------------------------------------------]|*5 2638{2:[No Name] [+] }| 2639[3:------------------------------------------------------------]| 2640## grid 2 2641incididunt ut labore et dolore magna aliqua. | 2642Ut enim ad minim veniam, quis nostrud | 2643exercitation ullamco laboris nisi ut aliquip ex | 2644ea commodo consequat. Duis aute irure dolor in | 2645reprehenderit in voluptate velit esse cillum | 2646## grid 3 2647{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2648## grid 4 2649Est ^ | 2650Lorem ipsum dolor sit amet, consectetur | 2651adipisicing elit, sed do eiusmod tempor | 2652incididunt ut labore et dolore magna aliqua. | 2653Ut enim ad minim veniam, quis nostrud | 2654exercitation ullamco laboris nisi ut aliquip ex | 2655## grid 5 2656{n: sunt }{12: }| 2657{n: in }{12: }| 2658{n: culpa }{12: }| 2659{n: qui }{12: }| 2660{n: officia }{12: }| 2661{n: deserunt }{12: }| 2662{n: mollit }{12: }| 2663{n: anim }{12: }| 2664{n: id }{12: }| 2665{n: est }{12: }| 2666{n: laborum }{c: }| 2667{12: Est }{c: }| 2668]] , 2669float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 3 , false , 100 , 1 , 1 , 3 } } , 2670} ) 2671else 2672screen : expect ( [[ 2673Est ^ | 2674L{n: sunt }{12: }sit amet, consectetur | 2675a{n: in }{12: }sed do eiusmod tempor | 2676i{n: culpa }{12: }re et dolore magna aliqua. | 2677U{n: qui }{12: }eniam, quis nostrud | 2678e{n: officia }{12: }co laboris nisi ut aliquip ex | 2679{3:[No}{n: deserunt }{12: }{3: }| 2680i{n: mollit }{12: }re et dolore magna aliqua. | 2681U{n: anim }{12: }eniam, quis nostrud | 2682e{n: id }{12: }co laboris nisi ut aliquip ex | 2683e{n: est }{12: }at. Duis aute irure dolor in | 2684r{n: laborum }{c: }oluptate velit esse cillum | 2685{2:[No}{12: Est }{c: }{2: }| 2686{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2687]] ) 2688end 2689 2690feed ( 'e' ) 2691if multigrid then 2692screen : expect ( { 2693grid =[[ 2694## grid 1 2695[4:------------------------------------------------------------]|*6 2696{3:[No Name] [+] }| 2697[2:------------------------------------------------------------]|*5 2698{2:[No Name] [+] }| 2699[3:------------------------------------------------------------]| 2700## grid 2 2701incididunt ut labore et dolore magna aliqua. | 2702Ut enim ad minim veniam, quis nostrud | 2703exercitation ullamco laboris nisi ut aliquip ex | 2704ea commodo consequat. Duis aute irure dolor in | 2705reprehenderit in voluptate velit esse cillum | 2706## grid 3 2707{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2708## grid 4 2709Est e^ | 2710Lorem ipsum dolor sit amet, consectetur | 2711adipisicing elit, sed do eiusmod tempor | 2712incididunt ut labore et dolore magna aliqua. | 2713Ut enim ad minim veniam, quis nostrud | 2714exercitation ullamco laboris nisi ut aliquip ex | 2715## grid 5 2716{n: elit }| 2717{n: eiusmod }| 2718{n: et }| 2719{n: enim }| 2720{n: exercitation }| 2721{n: ex }| 2722{n: ea }| 2723{n: esse }| 2724{n: eu }| 2725{12: est }| 2726]] , 2727float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 3 , false , 100 , 1 , 1 , 3 } } , 2728} ) 2729else 2730screen : expect ( [[ 2731Est e^ | 2732L{n: elit } sit amet, consectetur | 2733a{n: eiusmod } sed do eiusmod tempor | 2734i{n: et }ore et dolore magna aliqua. | 2735U{n: enim }veniam, quis nostrud | 2736e{n: exercitation }mco laboris nisi ut aliquip ex | 2737{3:[No}{n: ex }{3: }| 2738i{n: ea }ore et dolore magna aliqua. | 2739U{n: esse }veniam, quis nostrud | 2740e{n: eu }mco laboris nisi ut aliquip ex | 2741e{12: est }uat. Duis aute irure dolor in | 2742reprehenderit in voluptate velit esse cillum | 2743{2:[No Name] [+] }| 2744{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2745]] ) 2746end 2747 2748if send_mouse_grid then 2749api . nvim_input_mouse ( 'wheel' , 'up' , '' , 2 , 9 , 33 ) 2750else 2751api . nvim_input_mouse ( 'wheel' , 'up' , '' , 0 , 9 , 40 ) 2752end 2753if multigrid then 2754screen : expect ( { 2755grid =[[ 2756## grid 1 2757[4:------------------------------------------------------------]|*6 2758{3:[No Name] [+] }| 2759[2:------------------------------------------------------------]|*5 2760{2:[No Name] [+] }| 2761[3:------------------------------------------------------------]| 2762## grid 2 2763Est e | 2764Lorem ipsum dolor sit amet, consectetur | 2765adipisicing elit, sed do eiusmod tempor | 2766incididunt ut labore et dolore magna aliqua. | 2767Ut enim ad minim veniam, quis nostrud | 2768## grid 3 2769{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2770## grid 4 2771Est e^ | 2772Lorem ipsum dolor sit amet, consectetur | 2773adipisicing elit, sed do eiusmod tempor | 2774incididunt ut labore et dolore magna aliqua. | 2775Ut enim ad minim veniam, quis nostrud | 2776exercitation ullamco laboris nisi ut aliquip ex | 2777## grid 5 2778{n: elit }| 2779{n: eiusmod }| 2780{n: et }| 2781{n: enim }| 2782{n: exercitation }| 2783{n: ex }| 2784{n: ea }| 2785{n: esse }| 2786{n: eu }| 2787{12: est }| 2788]] , 2789float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 3 , false , 100 , 1 , 1 , 3 } } , 2790} ) 2791else 2792screen : expect ( [[ 2793Est e^ | 2794L{n: elit } sit amet, consectetur | 2795a{n: eiusmod } sed do eiusmod tempor | 2796i{n: et }ore et dolore magna aliqua. | 2797U{n: enim }veniam, quis nostrud | 2798e{n: exercitation }mco laboris nisi ut aliquip ex | 2799{3:[No}{n: ex }{3: }| 2800Est{n: ea } | 2801L{n: esse } sit amet, consectetur | 2802a{n: eu } sed do eiusmod tempor | 2803i{12: est }ore et dolore magna aliqua. | 2804Ut enim ad minim veniam, quis nostrud | 2805{2:[No Name] [+] }| 2806{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2807]] ) 2808end 2809 2810feed ( 's' ) 2811if multigrid then 2812screen : expect ( { 2813grid =[[ 2814## grid 1 2815[4:------------------------------------------------------------]|*6 2816{3:[No Name] [+] }| 2817[2:------------------------------------------------------------]|*5 2818{2:[No Name] [+] }| 2819[3:------------------------------------------------------------]| 2820## grid 2 2821Est es | 2822Lorem ipsum dolor sit amet, consectetur | 2823adipisicing elit, sed do eiusmod tempor | 2824incididunt ut labore et dolore magna aliqua. | 2825Ut enim ad minim veniam, quis nostrud | 2826## grid 3 2827{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2828## grid 4 2829Est es^ | 2830Lorem ipsum dolor sit amet, consectetur | 2831adipisicing elit, sed do eiusmod tempor | 2832incididunt ut labore et dolore magna aliqua. | 2833Ut enim ad minim veniam, quis nostrud | 2834exercitation ullamco laboris nisi ut aliquip ex | 2835## grid 5 2836{n: esse }| 2837{12: est }| 2838]] , 2839float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 3 , false , 100 , 1 , 1 , 3 } } , 2840} ) 2841else 2842screen : expect ( [[ 2843Est es^ | 2844L{n: esse } sit amet, consectetur | 2845a{12: est } sed do eiusmod tempor | 2846incididunt ut labore et dolore magna aliqua. | 2847Ut enim ad minim veniam, quis nostrud | 2848exercitation ullamco laboris nisi ut aliquip ex | 2849{3:[No Name] [+] }| 2850Est es | 2851Lorem ipsum dolor sit amet, consectetur | 2852adipisicing elit, sed do eiusmod tempor | 2853incididunt ut labore et dolore magna aliqua. | 2854Ut enim ad minim veniam, quis nostrud | 2855{2:[No Name] [+] }| 2856{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2857]] ) 2858end 2859 2860if send_mouse_grid then 2861api . nvim_input_mouse ( 'wheel' , 'down' , '' , 2 , 9 , 33 ) 2862else 2863api . nvim_input_mouse ( 'wheel' , 'down' , '' , 0 , 9 , 40 ) 2864end 2865if multigrid then 2866screen : expect ( { 2867grid =[[ 2868## grid 1 2869[4:------------------------------------------------------------]|*6 2870{3:[No Name] [+] }| 2871[2:------------------------------------------------------------]|*5 2872{2:[No Name] [+] }| 2873[3:------------------------------------------------------------]| 2874## grid 2 2875incididunt ut labore et dolore magna aliqua. | 2876Ut enim ad minim veniam, quis nostrud | 2877exercitation ullamco laboris nisi ut aliquip ex | 2878ea commodo consequat. Duis aute irure dolor in | 2879reprehenderit in voluptate velit esse cillum | 2880## grid 3 2881{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2882## grid 4 2883Est es^ | 2884Lorem ipsum dolor sit amet, consectetur | 2885adipisicing elit, sed do eiusmod tempor | 2886incididunt ut labore et dolore magna aliqua. | 2887Ut enim ad minim veniam, quis nostrud | 2888exercitation ullamco laboris nisi ut aliquip ex | 2889## grid 5 2890{n: esse }| 2891{12: est }| 2892]] , 2893float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 3 , false , 100 , 1 , 1 , 3 } } , 2894} ) 2895else 2896screen : expect ( [[ 2897Est es^ | 2898L{n: esse } sit amet, consectetur | 2899a{12: est } sed do eiusmod tempor | 2900incididunt ut labore et dolore magna aliqua. | 2901Ut enim ad minim veniam, quis nostrud | 2902exercitation ullamco laboris nisi ut aliquip ex | 2903{3:[No Name] [+] }| 2904incididunt ut labore et dolore magna aliqua. | 2905Ut enim ad minim veniam, quis nostrud | 2906exercitation ullamco laboris nisi ut aliquip ex | 2907ea commodo consequat. Duis aute irure dolor in | 2908reprehenderit in voluptate velit esse cillum | 2909{2:[No Name] [+] }| 2910{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2911]] ) 2912end 2913 2914feed ( '<bs>' ) 2915if multigrid then 2916screen : expect ( { 2917grid =[[ 2918## grid 1 2919[4:------------------------------------------------------------]|*6 2920{3:[No Name] [+] }| 2921[2:------------------------------------------------------------]|*5 2922{2:[No Name] [+] }| 2923[3:------------------------------------------------------------]| 2924## grid 2 2925incididunt ut labore et dolore magna aliqua. | 2926Ut enim ad minim veniam, quis nostrud | 2927exercitation ullamco laboris nisi ut aliquip ex | 2928ea commodo consequat. Duis aute irure dolor in | 2929reprehenderit in voluptate velit esse cillum | 2930## grid 3 2931{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2932## grid 4 2933Est e^ | 2934Lorem ipsum dolor sit amet, consectetur | 2935adipisicing elit, sed do eiusmod tempor | 2936incididunt ut labore et dolore magna aliqua. | 2937Ut enim ad minim veniam, quis nostrud | 2938exercitation ullamco laboris nisi ut aliquip ex | 2939## grid 5 2940{n: elit }| 2941{n: eiusmod }| 2942{n: et }| 2943{n: enim }| 2944{n: exercitation }| 2945{n: ex }| 2946{n: ea }| 2947{n: esse }| 2948{n: eu }| 2949{12: est }| 2950]] , 2951float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 3 , false , 100 , 1 , 1 , 3 } } , 2952} ) 2953else 2954screen : expect ( [[ 2955Est e^ | 2956L{n: elit } sit amet, consectetur | 2957a{n: eiusmod } sed do eiusmod tempor | 2958i{n: et }ore et dolore magna aliqua. | 2959U{n: enim }veniam, quis nostrud | 2960e{n: exercitation }mco laboris nisi ut aliquip ex | 2961{3:[No}{n: ex }{3: }| 2962i{n: ea }ore et dolore magna aliqua. | 2963U{n: esse }veniam, quis nostrud | 2964e{n: eu }mco laboris nisi ut aliquip ex | 2965e{12: est }uat. Duis aute irure dolor in | 2966reprehenderit in voluptate velit esse cillum | 2967{2:[No Name] [+] }| 2968{5:-- Keyword Local completion (^N^P) }{6:match 1 of 65} | 2969]] ) 2970end 2971 2972feed ( '<c-p>' ) 2973if multigrid then 2974screen : expect ( { 2975grid =[[ 2976## grid 1 2977[4:------------------------------------------------------------]|*6 2978{3:[No Name] [+] }| 2979[2:------------------------------------------------------------]|*5 2980{2:[No Name] [+] }| 2981[3:------------------------------------------------------------]| 2982## grid 2 2983incididunt ut labore et dolore magna aliqua. | 2984Ut enim ad minim veniam, quis nostrud | 2985exercitation ullamco laboris nisi ut aliquip ex | 2986ea commodo consequat. Duis aute irure dolor in | 2987reprehenderit in voluptate velit esse cillum | 2988## grid 3 2989{5:-- Keyword Local completion (^N^P) }{6:match 22 of 65} | 2990## grid 4 2991Est eu^ | 2992Lorem ipsum dolor sit amet, consectetur | 2993adipisicing elit, sed do eiusmod tempor | 2994incididunt ut labore et dolore magna aliqua. | 2995Ut enim ad minim veniam, quis nostrud | 2996exercitation ullamco laboris nisi ut aliquip ex | 2997## grid 5 2998{n: elit }| 2999{n: eiusmod }| 3000{n: et }| 3001{n: enim }| 3002{n: exercitation }| 3003{n: ex }| 3004{n: ea }| 3005{n: esse }| 3006{12: eu }| 3007{n: est }| 3008]] , 3009float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 3 , false , 100 , 1 , 1 , 3 } } , 3010} ) 3011else 3012screen : expect ( [[ 3013Est eu^ | 3014L{n: elit } sit amet, consectetur | 3015a{n: eiusmod } sed do eiusmod tempor | 3016i{n: et }ore et dolore magna aliqua. | 3017U{n: enim }veniam, quis nostrud | 3018e{n: exercitation }mco laboris nisi ut aliquip ex | 3019{3:[No}{n: ex }{3: }| 3020i{n: ea }ore et dolore magna aliqua. | 3021U{n: esse }veniam, quis nostrud | 3022e{12: eu }mco laboris nisi ut aliquip ex | 3023e{n: est }uat. Duis aute irure dolor in | 3024reprehenderit in voluptate velit esse cillum | 3025{2:[No Name] [+] }| 3026{5:-- Keyword Local completion (^N^P) }{6:match 22 of 65} | 3027]] ) 3028end 3029 3030if send_mouse_grid then 3031api . nvim_input_mouse ( 'wheel' , 'down' , '' , 2 , 9 , 33 ) 3032else 3033api . nvim_input_mouse ( 'wheel' , 'down' , '' , 0 , 9 , 40 ) 3034end 3035if multigrid then 3036screen : expect ( { 3037grid =[[ 3038## grid 1 3039[4:------------------------------------------------------------]|*6 3040{3:[No Name] [+] }| 3041[2:------------------------------------------------------------]|*5 3042{2:[No Name] [+] }| 3043[3:------------------------------------------------------------]| 3044## grid 2 3045ea commodo consequat. Duis aute irure dolor in | 3046reprehenderit in voluptate velit esse cillum | 3047dolore eu fugiat nulla pariatur. Excepteur sint | 3048occaecat cupidatat non proident, sunt in culpa | 3049qui officia deserunt mollit anim id est | 3050## grid 3 3051{5:-- Keyword Local completion (^N^P) }{6:match 22 of 65} | 3052## grid 4 3053Est eu^ | 3054Lorem ipsum dolor sit amet, consectetur | 3055adipisicing elit, sed do eiusmod tempor | 3056incididunt ut labore et dolore magna aliqua. | 3057Ut enim ad minim veniam, quis nostrud | 3058exercitation ullamco laboris nisi ut aliquip ex | 3059## grid 5 3060{n: elit }| 3061{n: eiusmod }| 3062{n: et }| 3063{n: enim }| 3064{n: exercitation }| 3065{n: ex }| 3066{n: ea }| 3067{n: esse }| 3068{12: eu }| 3069{n: est }| 3070]] , 3071float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 3 , false , 100 , 1 , 1 , 3 } } , 3072} ) 3073else 3074screen : expect ( [[ 3075Est eu^ | 3076L{n: elit } sit amet, consectetur | 3077a{n: eiusmod } sed do eiusmod tempor | 3078i{n: et }ore et dolore magna aliqua. | 3079U{n: enim }veniam, quis nostrud | 3080e{n: exercitation }mco laboris nisi ut aliquip ex | 3081{3:[No}{n: ex }{3: }| 3082e{n: ea }uat. Duis aute irure dolor in | 3083r{n: esse }voluptate velit esse cillum | 3084d{12: eu }nulla pariatur. Excepteur sint | 3085o{n: est }t non proident, sunt in culpa | 3086qui officia deserunt mollit anim id est | 3087{2:[No Name] [+] }| 3088{5:-- Keyword Local completion (^N^P) }{6:match 22 of 65} | 3089]] ) 3090end 3091 3092fn . complete ( 4 , { 'ea' , 'eeeeeeeeeeeeeeeeee' , 'ei' , 'eo' , 'eu' , 'ey' , 'eå' , 'eä' , 'eö' } ) 3093if multigrid then 3094screen : expect ( { 3095grid =[[ 3096## grid 1 3097[4:------------------------------------------------------------]|*6 3098{3:[No Name] [+] }| 3099[2:------------------------------------------------------------]|*5 3100{2:[No Name] [+] }| 3101[3:------------------------------------------------------------]| 3102## grid 2 3103ea commodo consequat. Duis aute irure dolor in | 3104reprehenderit in voluptate velit esse cillum | 3105dolore eu fugiat nulla pariatur. Excepteur sint | 3106occaecat cupidatat non proident, sunt in culpa | 3107qui officia deserunt mollit anim id est | 3108## grid 3 3109{5:-- INSERT --} | 3110## grid 4 3111Est eu^ | 3112Lorem ipsum dolor sit amet, consectetur | 3113adipisicing elit, sed do eiusmod tempor | 3114incididunt ut labore et dolore magna aliqua. | 3115Ut enim ad minim veniam, quis nostrud | 3116exercitation ullamco laboris nisi ut aliquip ex | 3117## grid 5 3118{12: ea }| 3119{n: eeeeeeeeeeeeeeeeee }| 3120{n: ei }| 3121{n: eo }| 3122{n: eu }| 3123{n: ey }| 3124{n: eå }| 3125{n: eä }| 3126{n: eö }| 3127]] , 3128float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 2 , false , 100 , 1 , 1 , 2 } } , 3129} ) 3130else 3131screen : expect ( [[ 3132Est eu^ | 3133{12: ea }t amet, consectetur | 3134{n: eeeeeeeeeeeeeeeeee }d do eiusmod tempor | 3135{n: ei } et dolore magna aliqua. | 3136{n: eo }iam, quis nostrud | 3137{n: eu } laboris nisi ut aliquip ex | 3138{3:[N}{n: ey }{3: }| 3139{n: eå }. Duis aute irure dolor in | 3140{n: eä }uptate velit esse cillum | 3141{n: eö }la pariatur. Excepteur sint | 3142occaecat cupidatat non proident, sunt in culpa | 3143qui officia deserunt mollit anim id est | 3144{2:[No Name] [+] }| 3145{5:-- INSERT --} | 3146]] ) 3147end 3148 3149fn . complete ( 4 , { 'ea' , 'eee' , 'ei' , 'eo' , 'eu' , 'ey' , 'eå' , 'eä' , 'eö' } ) 3150if multigrid then 3151screen : expect ( { 3152grid =[[ 3153## grid 1 3154[4:------------------------------------------------------------]|*6 3155{3:[No Name] [+] }| 3156[2:------------------------------------------------------------]|*5 3157{2:[No Name] [+] }| 3158[3:------------------------------------------------------------]| 3159## grid 2 3160ea commodo consequat. Duis aute irure dolor in | 3161reprehenderit in voluptate velit esse cillum | 3162dolore eu fugiat nulla pariatur. Excepteur sint | 3163occaecat cupidatat non proident, sunt in culpa | 3164qui officia deserunt mollit anim id est | 3165## grid 3 3166{5:-- INSERT --} | 3167## grid 4 3168Est eu^ | 3169Lorem ipsum dolor sit amet, consectetur | 3170adipisicing elit, sed do eiusmod tempor | 3171incididunt ut labore et dolore magna aliqua. | 3172Ut enim ad minim veniam, quis nostrud | 3173exercitation ullamco laboris nisi ut aliquip ex | 3174## grid 5 3175{12: ea }| 3176{n: eee }| 3177{n: ei }| 3178{n: eo }| 3179{n: eu }| 3180{n: ey }| 3181{n: eå }| 3182{n: eä }| 3183{n: eö }| 3184]] , 3185float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 2 , false , 100 , 1 , 1 , 2 } } , 3186} ) 3187else 3188screen : expect ( [[ 3189Est eu^ | 3190{12: ea }r sit amet, consectetur | 3191{n: eee }, sed do eiusmod tempor | 3192{n: ei }bore et dolore magna aliqua. | 3193{n: eo } veniam, quis nostrud | 3194{n: eu }amco laboris nisi ut aliquip ex | 3195{3:[N}{n: ey }{3: }| 3196{n: eå }quat. Duis aute irure dolor in | 3197{n: eä } voluptate velit esse cillum | 3198{n: eö } nulla pariatur. Excepteur sint | 3199occaecat cupidatat non proident, sunt in culpa | 3200qui officia deserunt mollit anim id est | 3201{2:[No Name] [+] }| 3202{5:-- INSERT --} | 3203]] ) 3204end 3205 3206feed ( '<c-n>' ) 3207if multigrid then 3208screen : expect ( { 3209grid =[[ 3210## grid 1 3211[4:------------------------------------------------------------]|*6 3212{3:[No Name] [+] }| 3213[2:------------------------------------------------------------]|*5 3214{2:[No Name] [+] }| 3215[3:------------------------------------------------------------]| 3216## grid 2 3217ea commodo consequat. Duis aute irure dolor in | 3218reprehenderit in voluptate velit esse cillum | 3219dolore eu fugiat nulla pariatur. Excepteur sint | 3220occaecat cupidatat non proident, sunt in culpa | 3221qui officia deserunt mollit anim id est | 3222## grid 3 3223{5:-- INSERT --} | 3224## grid 4 3225Esteee^ | 3226Lorem ipsum dolor sit amet, consectetur | 3227adipisicing elit, sed do eiusmod tempor | 3228incididunt ut labore et dolore magna aliqua. | 3229Ut enim ad minim veniam, quis nostrud | 3230exercitation ullamco laboris nisi ut aliquip ex | 3231## grid 5 3232{n: ea }| 3233{12: eee }| 3234{n: ei }| 3235{n: eo }| 3236{n: eu }| 3237{n: ey }| 3238{n: eå }| 3239{n: eä }| 3240{n: eö }| 3241]] , 3242float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 2 , false , 100 , 1 , 1 , 2 } } , 3243} ) 3244else 3245screen : expect ( [[ 3246Esteee^ | 3247{n: ea }r sit amet, consectetur | 3248{12: eee }, sed do eiusmod tempor | 3249{n: ei }bore et dolore magna aliqua. | 3250{n: eo } veniam, quis nostrud | 3251{n: eu }amco laboris nisi ut aliquip ex | 3252{3:[N}{n: ey }{3: }| 3253{n: eå }quat. Duis aute irure dolor in | 3254{n: eä } voluptate velit esse cillum | 3255{n: eö } nulla pariatur. Excepteur sint | 3256occaecat cupidatat non proident, sunt in culpa | 3257qui officia deserunt mollit anim id est | 3258{2:[No Name] [+] }| 3259{5:-- INSERT --} | 3260]] ) 3261end 3262 3263fn . complete ( 6 , { 'foo' , 'bar' } ) 3264if multigrid then 3265screen : expect ( { 3266grid =[[ 3267## grid 1 3268[4:------------------------------------------------------------]|*6 3269{3:[No Name] [+] }| 3270[2:------------------------------------------------------------]|*5 3271{2:[No Name] [+] }| 3272[3:------------------------------------------------------------]| 3273## grid 2 3274ea commodo consequat. Duis aute irure dolor in | 3275reprehenderit in voluptate velit esse cillum | 3276dolore eu fugiat nulla pariatur. Excepteur sint | 3277occaecat cupidatat non proident, sunt in culpa | 3278qui officia deserunt mollit anim id est | 3279## grid 3 3280{5:-- INSERT --} | 3281## grid 4 3282Esteee^ | 3283Lorem ipsum dolor sit amet, consectetur | 3284adipisicing elit, sed do eiusmod tempor | 3285incididunt ut labore et dolore magna aliqua. | 3286Ut enim ad minim veniam, quis nostrud | 3287exercitation ullamco laboris nisi ut aliquip ex | 3288## grid 5 3289{12: foo }| 3290{n: bar }| 3291]] , 3292float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , 4 , false , 100 , 1 , 1 , 4 } } , 3293} ) 3294else 3295screen : expect ( [[ 3296Esteee^ | 3297Lo{12: foo }sit amet, consectetur | 3298ad{n: bar }sed do eiusmod tempor | 3299incididunt ut labore et dolore magna aliqua. | 3300Ut enim ad minim veniam, quis nostrud | 3301exercitation ullamco laboris nisi ut aliquip ex | 3302{3:[No Name] [+] }| 3303ea commodo consequat. Duis aute irure dolor in | 3304reprehenderit in voluptate velit esse cillum | 3305dolore eu fugiat nulla pariatur. Excepteur sint | 3306occaecat cupidatat non proident, sunt in culpa | 3307qui officia deserunt mollit anim id est | 3308{2:[No Name] [+] }| 3309{5:-- INSERT --} | 3310]] ) 3311end 3312 3313feed ( '<c-y>' ) 3314if multigrid then 3315screen : expect ( [[ 3316## grid 1 3317[4:------------------------------------------------------------]|*6 3318{3:[No Name] [+] }| 3319[2:------------------------------------------------------------]|*5 3320{2:[No Name] [+] }| 3321[3:------------------------------------------------------------]| 3322## grid 2 3323ea commodo consequat. Duis aute irure dolor in | 3324reprehenderit in voluptate velit esse cillum | 3325dolore eu fugiat nulla pariatur. Excepteur sint | 3326occaecat cupidatat non proident, sunt in culpa | 3327qui officia deserunt mollit anim id est | 3328## grid 3 3329{5:-- INSERT --} | 3330## grid 4 3331Esteefoo^ | 3332Lorem ipsum dolor sit amet, consectetur | 3333adipisicing elit, sed do eiusmod tempor | 3334incididunt ut labore et dolore magna aliqua. | 3335Ut enim ad minim veniam, quis nostrud | 3336exercitation ullamco laboris nisi ut aliquip ex | 3337]] ) 3338else 3339screen : expect ( [[ 3340Esteefoo^ | 3341Lorem ipsum dolor sit amet, consectetur | 3342adipisicing elit, sed do eiusmod tempor | 3343incididunt ut labore et dolore magna aliqua. | 3344Ut enim ad minim veniam, quis nostrud | 3345exercitation ullamco laboris nisi ut aliquip ex | 3346{3:[No Name] [+] }| 3347ea commodo consequat. Duis aute irure dolor in | 3348reprehenderit in voluptate velit esse cillum | 3349dolore eu fugiat nulla pariatur. Excepteur sint | 3350occaecat cupidatat non proident, sunt in culpa | 3351qui officia deserunt mollit anim id est | 3352{2:[No Name] [+] }| 3353{5:-- INSERT --} | 3354]] ) 3355end 3356end ) 3357 3358it ( 'can be moved due to wrap or resize' , function () 3359feed ( 'isome long prefix before the ' ) 3360command ( 'set completeopt+=noinsert,noselect' ) 3361command ( 'set linebreak' ) 3362fn . complete ( 29 , { 'word' , 'choice' , 'text' , 'thing' } ) 3363if multigrid then 3364screen : expect ( { 3365grid =[[ 3366## grid 1 3367[2:--------------------------------]|*19 3368[3:--------------------------------]| 3369## grid 2 3370some long prefix before the ^ | 3371{1:~ }|*18 3372## grid 3 3373{5:-- INSERT --} | 3374## grid 4 3375{n: word }| 3376{n: choice }| 3377{n: text }| 3378{n: thing }| 3379]] , 3380float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 15 , false , 100 , 1 , 1 , 15 } } , 3381} ) 3382else 3383screen : expect ( [[ 3384some long prefix before the ^ | 3385{1:~ }{n: word }| 3386{1:~ }{n: choice }| 3387{1:~ }{n: text }| 3388{1:~ }{n: thing }| 3389{1:~ }|*14 3390{5:-- INSERT --} | 3391]] ) 3392end 3393 3394feed ( '<c-p>' ) 3395if multigrid then 3396screen : expect ( { 3397grid =[[ 3398## grid 1 3399[2:--------------------------------]|*19 3400[3:--------------------------------]| 3401## grid 2 3402some long prefix before the | 3403thing^ | 3404{1:~ }|*17 3405## grid 3 3406{5:-- INSERT --} | 3407## grid 4 3408{n:word }| 3409{n:choice }| 3410{n:text }| 3411{12:thing }| 3412]] , 3413float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 3414} ) 3415else 3416screen : expect ( [[ 3417some long prefix before the | 3418thing^ | 3419{n:word }{1: }| 3420{n:choice }{1: }| 3421{n:text }{1: }| 3422{12:thing }{1: }| 3423{1:~ }|*13 3424{5:-- INSERT --} | 3425]] ) 3426end 3427 3428feed ( '<c-p>' ) 3429if multigrid then 3430screen : expect ( { 3431grid =[[ 3432## grid 1 3433[2:--------------------------------]|*19 3434[3:--------------------------------]| 3435## grid 2 3436some long prefix before the text| 3437{1:^~ }| 3438{1:~ }|*17 3439## grid 3 3440{5:-- INSERT --} | 3441## grid 4 3442{n: word }| 3443{n: choice }| 3444{12: text }| 3445{n: thing }| 3446]] , 3447float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 15 , false , 100 , 1 , 1 , 15 } } , 3448} ) 3449else 3450screen : expect ( [[ 3451some long prefix before the text| 3452{1:^~ }{n: word }| 3453{1:~ }{n: choice }| 3454{1:~ }{12: text }| 3455{1:~ }{n: thing }| 3456{1:~ }|*14 3457{5:-- INSERT --} | 3458]] ) 3459end 3460 3461screen : try_resize ( 30 , 8 ) 3462if multigrid then 3463screen : expect ( { 3464grid =[[ 3465## grid 1 3466[2:------------------------------]|*7 3467[3:------------------------------]| 3468## grid 2 3469some long prefix before the | 3470text^ | 3471{1:~ }|*5 3472## grid 3 3473{5:-- INSERT --} | 3474## grid 4 3475{n:word }| 3476{n:choice }| 3477{12:text }| 3478{n:thing }| 3479]] , 3480float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 3481} ) 3482else 3483screen : expect ( [[ 3484some long prefix before the | 3485text^ | 3486{n:word }{1: }| 3487{n:choice }{1: }| 3488{12:text }{1: }| 3489{n:thing }{1: }| 3490{1:~ }| 3491{5:-- INSERT --} | 3492]] ) 3493end 3494 3495screen : try_resize ( 50 , 8 ) 3496if multigrid then 3497screen : expect ( { 3498grid =[[ 3499## grid 1 3500[2:--------------------------------------------------]|*7 3501[3:--------------------------------------------------]| 3502## grid 2 3503some long prefix before the text^ | 3504{1:~ }|*6 3505## grid 3 3506{5:-- INSERT --} | 3507## grid 4 3508{n: word }| 3509{n: choice }| 3510{12: text }| 3511{n: thing }| 3512]] , 3513float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 27 , false , 100 , 1 , 1 , 27 } } , 3514} ) 3515else 3516screen : expect ( [[ 3517some long prefix before the text^ | 3518{1:~ }{n: word }{1: }| 3519{1:~ }{n: choice }{1: }| 3520{1:~ }{12: text }{1: }| 3521{1:~ }{n: thing }{1: }| 3522{1:~ }|*2 3523{5:-- INSERT --} | 3524]] ) 3525end 3526 3527screen : try_resize ( 25 , 10 ) 3528if multigrid then 3529screen : expect ( { 3530grid =[[ 3531## grid 1 3532[2:-------------------------]|*9 3533[3:-------------------------]| 3534## grid 2 3535some long prefix before | 3536the text^ | 3537{1:~ }|*7 3538## grid 3 3539{5:-- INSERT --} | 3540## grid 4 3541{n: word }| 3542{n: choice }| 3543{12: text }| 3544{n: thing }| 3545]] , 3546float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 3 , false , 100 , 1 , 2 , 3 } } , 3547} ) 3548else 3549screen : expect ( [[ 3550some long prefix before | 3551the text^ | 3552{1:~ }{n: word }{1: }| 3553{1:~ }{n: choice }{1: }| 3554{1:~ }{12: text }{1: }| 3555{1:~ }{n: thing }{1: }| 3556{1:~ }|*3 3557{5:-- INSERT --} | 3558]] ) 3559end 3560 3561screen : try_resize ( 12 , 5 ) 3562if multigrid then 3563screen : expect ( { 3564grid =[[ 3565## grid 1 3566[2:------------]|*4 3567[3:------------]| 3568## grid 2 3569some long | 3570prefix | 3571before the | 3572text^ | 3573## grid 3 3574{5:-- INSERT --}| 3575## grid 4 3576{n: word }| 3577{n: choice }| 3578{12: text }| 3579{n: thing }| 3580]] , 3581float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 3 , false , 100 , 1 , 2 , 3 } } , 3582} ) 3583else 3584screen : expect ( [[ 3585some long | 3586prefix | 3587bef{n: word } | 3588tex{n: }^ | 3589{5:-- INSERT --}| 3590]] ) 3591end 3592 3593-- can't draw the pum, but check we don't crash 3594screen : try_resize ( 12 , 2 ) 3595if multigrid then 3596screen : expect ( { 3597grid =[[ 3598## grid 1 3599[2:------------]| 3600[3:------------]| 3601## grid 2 3602{1:<<<}t^ | 3603## grid 3 3604{5:-- INSERT --}| 3605## grid 4 3606{n: word }| 3607{n: choice }| 3608{12: text }| 3609{n: thing }| 3610]] , 3611float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 3 , false , 100 , 1 , 2 , 3 } } , 3612} ) 3613else 3614screen : expect ( [[ 3615{1:<<<}t^ | 3616{5:-- INSERT --}| 3617]] ) 3618end 3619 3620-- but state is preserved, pum reappears 3621screen : try_resize ( 20 , 8 ) 3622if multigrid then 3623screen : expect ( { 3624grid =[[ 3625## grid 1 3626[2:--------------------]|*7 3627[3:--------------------]| 3628## grid 2 3629some long prefix | 3630before the text^ | 3631{1:~ }|*5 3632## grid 3 3633{5:-- INSERT --} | 3634## grid 4 3635{n: word }| 3636{n: choice }| 3637{12: text }| 3638{n: thing }| 3639]] , 3640float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 3 , false , 100 , 1 , 2 , 3 } } , 3641} ) 3642else 3643screen : expect ( [[ 3644some long prefix | 3645before the text^ | 3646{1:~ }{n: word }| 3647{1:~ }{n: choice }| 3648{1:~ }{12: text }| 3649{1:~ }{n: thing }| 3650{1:~ }| 3651{5:-- INSERT --} | 3652]] ) 3653end 3654end ) 3655 3656it ( 'with VimResized autocmd' , function () 3657feed ( 'isome long prefix before the ' ) 3658command ( 'set completeopt+=noinsert,noselect pumwidth=12' ) 3659command ( 'autocmd VimResized * redraw!' ) 3660command ( 'set linebreak' ) 3661fn . complete ( 29 , { 'word' , 'choice' , 'text' , 'thing' } ) 3662if multigrid then 3663screen : expect ( { 3664grid =[[ 3665## grid 1 3666[2:--------------------------------]|*19 3667[3:--------------------------------]| 3668## grid 2 3669some long prefix before the ^ | 3670{1:~ }|*18 3671## grid 3 3672{5:-- INSERT --} | 3673## grid 4 3674{n: word }| 3675{n: choice }| 3676{n: text }| 3677{n: thing }| 3678]] , 3679float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 18 , false , 100 , 1 , 1 , 18 } } , 3680} ) 3681else 3682screen : expect ( [[ 3683some long prefix before the ^ | 3684{1:~ }{n: word }| 3685{1:~ }{n: choice }| 3686{1:~ }{n: text }| 3687{1:~ }{n: thing }| 3688{1:~ }|*14 3689{5:-- INSERT --} | 3690]] ) 3691end 3692 3693screen : try_resize ( 16 , 10 ) 3694if multigrid then 3695screen : expect ( { 3696grid =[[ 3697## grid 1 3698[2:----------------]|*9 3699[3:----------------]| 3700## grid 2 3701some long | 3702prefix before | 3703the ^ | 3704{1:~ }|*6 3705## grid 3 3706{5:-- INSERT --} | 3707## grid 4 3708{n: word }| 3709{n: choice }| 3710{n: text }| 3711{n: thing }| 3712]] , 3713float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 3 , 3 , false , 100 , 1 , 3 , 3 } } , 3714} ) 3715else 3716screen : expect ( [[ 3717some long | 3718prefix before | 3719the ^ | 3720{1:~ }{n: word }| 3721{1:~ }{n: choice }| 3722{1:~ }{n: text }| 3723{1:~ }{n: thing }| 3724{1:~ }|*2 3725{5:-- INSERT --} | 3726]] ) 3727end 3728end ) 3729 3730it ( 'with rightleft window' , function () 3731command ( 'set rl wildoptions+=pum' ) 3732feed ( 'isome rightleft ' ) 3733if multigrid then 3734screen : expect ( [[ 3735## grid 1 3736[2:--------------------------------]|*19 3737[3:--------------------------------]| 3738## grid 2 3739^ tfelthgir emos| 3740{1: ~}|*18 3741## grid 3 3742{5:-- INSERT --} | 3743]] ) 3744else 3745screen : expect ( [[ 3746^ tfelthgir emos| 3747{1: ~}|*18 3748{5:-- INSERT --} | 3749]] ) 3750end 3751 3752command ( 'set completeopt+=noinsert,noselect' ) 3753fn . complete ( 16 , { 'word' , 'choice' , 'text' , 'thing' } ) 3754if multigrid then 3755screen : expect ( { 3756grid =[[ 3757## grid 1 3758[2:--------------------------------]|*19 3759[3:--------------------------------]| 3760## grid 2 3761^ tfelthgir emos| 3762{1: ~}|*18 3763## grid 3 3764{5:-- INSERT --} | 3765## grid 4 3766{n: drow }| 3767{n: eciohc }| 3768{n: txet }| 3769{n: gniht }| 3770]] , 3771float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 2 , false , 100 , 1 , 1 , 2 } } , 3772} ) 3773else 3774screen : expect ( [[ 3775^ tfelthgir emos| 3776{1: }{n: drow }{1: ~}| 3777{1: }{n: eciohc }{1: ~}| 3778{1: }{n: txet }{1: ~}| 3779{1: }{n: gniht }{1: ~}| 3780{1: ~}|*14 3781{5:-- INSERT --} | 3782]] ) 3783end 3784 3785feed ( '<c-n>' ) 3786if multigrid then 3787screen : expect ( { 3788grid =[[ 3789## grid 1 3790[2:--------------------------------]|*19 3791[3:--------------------------------]| 3792## grid 2 3793^ drow tfelthgir emos| 3794{1: ~}|*18 3795## grid 3 3796{5:-- INSERT --} | 3797## grid 4 3798{12: drow }| 3799{n: eciohc }| 3800{n: txet }| 3801{n: gniht }| 3802]] , 3803float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 2 , false , 100 , 1 , 1 , 2 } } , 3804} ) 3805else 3806screen : expect ( [[ 3807^ drow tfelthgir emos| 3808{1: }{12: drow }{1: ~}| 3809{1: }{n: eciohc }{1: ~}| 3810{1: }{n: txet }{1: ~}| 3811{1: }{n: gniht }{1: ~}| 3812{1: ~}|*14 3813{5:-- INSERT --} | 3814]] ) 3815end 3816 3817feed ( '<c-y>' ) 3818if multigrid then 3819screen : expect ( [[ 3820## grid 1 3821[2:--------------------------------]|*19 3822[3:--------------------------------]| 3823## grid 2 3824^ drow tfelthgir emos| 3825{1: ~}|*18 3826## grid 3 3827{5:-- INSERT --} | 3828]] ) 3829else 3830screen : expect ( [[ 3831^ drow tfelthgir emos| 3832{1: ~}|*18 3833{5:-- INSERT --} | 3834]] ) 3835end 3836 3837-- oldtest: Test_wildmenu_pum_rightleft() 3838feed ( '<esc>:sign ' ) 3839if multigrid then 3840screen : expect ( [[ 3841## grid 1 3842[2:--------------------------------]|*19 3843[3:--------------------------------]| 3844## grid 2 3845drow tfelthgir emos| 3846{1: ~}|*18 3847## grid 3 3848:sign ^ | 3849]] ) 3850else 3851screen : expect ( [[ 3852drow tfelthgir emos| 3853{1: ~}|*18 3854:sign ^ | 3855]] ) 3856end 3857-- Not rightleft on the cmdline. 3858feed ( '<Tab>' ) 3859if multigrid then 3860screen : expect ( { 3861grid =[[ 3862## grid 1 3863[2:--------------------------------]|*19 3864[3:--------------------------------]| 3865## grid 2 3866drow tfelthgir emos| 3867{1: ~}|*18 3868## grid 3 3869:sign define^ | 3870## grid 4 3871{12: define }| 3872{n: jump }| 3873{n: list }| 3874{n: place }| 3875{n: undefine }| 3876{n: unplace }| 3877]] , 3878float_pos ={ [ 4 ] ={ - 1 , 'SW' , 1 , 19 , 5 , false , 250 , 2 , 13 , 5 } } , 3879} ) 3880else 3881screen : expect ( [[ 3882drow tfelthgir emos| 3883{1: ~}|*12 3884{1: }{12: define }{1: ~}| 3885{1: }{n: jump }{1: ~}| 3886{1: }{n: list }{1: ~}| 3887{1: }{n: place }{1: ~}| 3888{1: }{n: undefine }{1: ~}| 3889{1: }{n: unplace }{1: ~}| 3890:sign define^ | 3891]] ) 3892end 3893 3894-- Behavior is the same when using 'keymap'. 3895feed ( '<Esc>' ) 3896command ( 'set keymap=dvorak' ) 3897-- ";gul" -> "sign" when using Dvorak keymap. 3898feed ( ':<C-^>;gul <Tab>' ) 3899screen : expect_unchanged ( true ) 3900feed ( '<Esc>' ) 3901command ( 'set keymap&' ) 3902end ) 3903 3904it ( 'with rightleft vsplits' , function () 3905screen : try_resize ( 40 , 6 ) 3906command ( 'set rightleft' ) 3907command ( 'rightbelow vsplit' ) 3908command ( 'set completeopt+=noinsert,noselect' ) 3909command ( 'set pumheight=2' ) 3910feed ( 'isome rightleft ' ) 3911fn . complete ( 16 , { 'word' , 'choice' , 'text' , 'thing' } ) 3912if multigrid then 3913screen : expect { 3914grid =[[ 3915## grid 1 3916[2:-------------------]│[4:--------------------]|*4 3917{2:[No Name] [+] }{3:[No Name] [+] }| 3918[3:----------------------------------------]| 3919## grid 2 3920tfelthgir emos| 3921{1: ~}|*3 3922## grid 3 3923{5:-- INSERT --} | 3924## grid 4 3925^ tfelthgir emos| 3926{1: ~}|*3 3927## grid 5 3928{c: }{n: drow }| 3929{12: }{n: eciohc }| 3930]] , 3931float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 1 , - 11 , false , 100 , 1 , 1 , 9 } } , 3932} 3933else 3934screen : expect ( [[ 3935tfelthgir emos│ ^ tfelthgir emos| 3936{1: }{c: }{n: drow }{1: ~}| 3937{1: }{12: }{n: eciohc }{1: ~}| 3938{1: ~}│{1: ~}| 3939{2:[No Name] [+] }{3:[No Name] [+] }| 3940{5:-- INSERT --} | 3941]] ) 3942end 3943feed ( '<C-E><CR>' ) 3944fn . complete ( 1 , { 'word' , 'choice' , 'text' , 'thing' } ) 3945if multigrid then 3946screen : expect { 3947grid =[[ 3948## grid 1 3949[2:-------------------]│[4:--------------------]|*4 3950{2:[No Name] [+] }{3:[No Name] [+] }| 3951[3:----------------------------------------]| 3952## grid 2 3953tfelthgir emos| 3954| 3955{1: ~}|*2 3956## grid 3 3957{5:-- INSERT --} | 3958## grid 4 3959tfelthgir emos| 3960^ | 3961{1: ~}|*2 3962## grid 5 3963{c: }{n: drow}| 3964{12: }{n: eciohc}| 3965]] , 3966float_pos ={ [ 5 ] ={ - 1 , 'NW' , 4 , 2 , 4 , false , 100 , 1 , 2 , 24 } } , 3967} 3968else 3969screen : expect ( [[ 3970tfelthgir emos│ tfelthgir emos| 3971│ ^ | 3972{1: ~}│{1: }{c: }{n: drow}| 3973{1: ~}│{1: }{12: }{n: eciohc}| 3974{2:[No Name] [+] }{3:[No Name] [+] }| 3975{5:-- INSERT --} | 3976]] ) 3977end 3978feed ( '<C-E>' ) 3979async_meths . nvim_call_function ( 'input' , { '' , '' , 'sign' } ) 3980if multigrid then 3981screen : expect ( [[ 3982## grid 1 3983[2:-------------------]│[4:--------------------]|*4 3984{2:[No Name] [+] }{3:[No Name] [+] }| 3985[3:----------------------------------------]| 3986## grid 2 3987tfelthgir emos| 3988| 3989{1: ~}|*2 3990## grid 3 3991^ | 3992## grid 4 3993tfelthgir emos| 3994| 3995{1: ~}|*2 3996]] ) 3997else 3998screen : expect ( [[ 3999tfelthgir emos│ tfelthgir emos| 4000│ | 4001{1: ~}│{1: ~}|*2 4002{2:[No Name] [+] }{3:[No Name] [+] }| 4003^ | 4004]] ) 4005end 4006command ( 'set wildoptions+=pum' ) 4007feed ( '<Tab>' ) 4008if multigrid then 4009screen : expect { 4010grid =[[ 4011## grid 1 4012[2:-------------------]│[4:--------------------]|*4 4013{2:[No Name] [+] }{3:[No Name] [+] }| 4014[3:----------------------------------------]| 4015## grid 2 4016tfelthgir emos| 4017| 4018{1: ~}|*2 4019## grid 3 4020define^ | 4021## grid 4 4022tfelthgir emos| 4023| 4024{1: ~}|*2 4025## grid 5 4026{12:define }{c: }| 4027{n:jump }{12: }| 4028]] , 4029float_pos ={ [ 5 ] ={ - 1 , 'SW' , 1 , 5 , 0 , false , 250 , 2 , 3 , 0 } } , 4030} 4031else 4032screen : expect ( [[ 4033tfelthgir emos│ tfelthgir emos| 4034│ | 4035{1: ~}│{1: ~}| 4036{12:define }{c: }{1: ~}│{1: ~}| 4037{n:jump }{12: }{2: }{3:[No Name] [+] }| 4038define^ | 4039]] ) 4040end 4041end ) 4042 4043it ( 'with multiline messages' , function () 4044screen : try_resize ( 40 , 8 ) 4045feed ( 'ixx<cr>' ) 4046command ( 'imap <f2> <cmd>echoerr "very"\\|echoerr "much"\\|echoerr "error"<cr>' ) 4047fn . complete ( 1 , { 'word' , 'choice' , 'text' , 'thing' } ) 4048if multigrid then 4049screen : expect ( { 4050grid =[[ 4051## grid 1 4052[2:----------------------------------------]|*7 4053[3:----------------------------------------]| 4054## grid 2 4055xx | 4056word^ | 4057{1:~ }|*5 4058## grid 3 4059{5:-- INSERT --} | 4060## grid 4 4061{12:word }| 4062{n:choice }| 4063{n:text }| 4064{n:thing }| 4065]] , 4066float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 4067} ) 4068else 4069screen : expect ( [[ 4070xx | 4071word^ | 4072{12:word }{1: }| 4073{n:choice }{1: }| 4074{n:text }{1: }| 4075{n:thing }{1: }| 4076{1:~ }| 4077{5:-- INSERT --} | 4078]] ) 4079end 4080 4081feed ( '<f2>' ) 4082if multigrid then 4083screen : expect ( { 4084grid =[[ 4085## grid 1 4086[2:----------------------------------------]|*4 4087[3:----------------------------------------]|*4 4088## grid 2 4089xx | 4090word | 4091{1:~ }|*5 4092## grid 3 4093{9:very} | 4094{9:much} | 4095{9:error} | 4096{6:Press ENTER or type command to continue}^ | 4097## grid 4 4098{12:word }| 4099{n:choice }| 4100{n:text }| 4101{n:thing }| 4102]] , 4103float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 4104} ) 4105else 4106screen : expect ( [[ 4107xx | 4108word | 4109{12:word }{1: }| 4110{3: }| 4111{9:very} | 4112{9:much} | 4113{9:error} | 4114{6:Press ENTER or type command to continue}^ | 4115]] ) 4116end 4117 4118feed ( '<cr>' ) 4119if multigrid then 4120screen : expect ( { 4121grid =[[ 4122## grid 1 4123[2:----------------------------------------]|*7 4124[3:----------------------------------------]| 4125## grid 2 4126xx | 4127word^ | 4128{1:~ }|*5 4129## grid 3 4130{5:-- INSERT --} | 4131## grid 4 4132{12:word }| 4133{n:choice }| 4134{n:text }| 4135{n:thing }| 4136]] , 4137float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 4138} ) 4139else 4140screen : expect ( [[ 4141xx | 4142word^ | 4143{12:word }{1: }| 4144{n:choice }{1: }| 4145{n:text }{1: }| 4146{n:thing }{1: }| 4147{1:~ }| 4148{5:-- INSERT --} | 4149]] ) 4150end 4151 4152feed ( '<c-n>' ) 4153if multigrid then 4154screen : expect ( { 4155grid =[[ 4156## grid 1 4157[2:----------------------------------------]|*7 4158[3:----------------------------------------]| 4159## grid 2 4160xx | 4161choice^ | 4162{1:~ }|*5 4163## grid 3 4164{5:-- INSERT --} | 4165## grid 4 4166{n:word }| 4167{12:choice }| 4168{n:text }| 4169{n:thing }| 4170]] , 4171float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 4172} ) 4173else 4174screen : expect ( [[ 4175xx | 4176choice^ | 4177{n:word }{1: }| 4178{12:choice }{1: }| 4179{n:text }{1: }| 4180{n:thing }{1: }| 4181{1:~ }| 4182{5:-- INSERT --} | 4183]] ) 4184end 4185 4186command ( 'split' ) 4187feed ( '<c-u>' ) 4188fn . complete ( 1 , { 'word' , 'choice' , 'text' , 'thing' } ) 4189if multigrid then 4190screen : expect ( { 4191grid =[[ 4192## grid 1 4193[5:----------------------------------------]|*3 4194{3:[No Name] [+] }| 4195[2:----------------------------------------]|*2 4196{2:[No Name] [+] }| 4197[3:----------------------------------------]| 4198## grid 2 4199xx | 4200word | 4201## grid 3 4202{5:-- INSERT --} | 4203## grid 4 4204{12:word }| 4205{n:choice }| 4206{n:text }| 4207{n:thing }| 4208## grid 5 4209xx | 4210word^ | 4211{1:~ }| 4212]] , 4213float_pos ={ [ 4 ] ={ - 1 , 'NW' , 5 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 4214} ) 4215else 4216screen : expect ( [[ 4217xx | 4218word^ | 4219{12:word }{1: }| 4220{n:choice }{3: }| 4221{n:text } | 4222{n:thing } | 4223{2:[No Name] [+] }| 4224{5:-- INSERT --} | 4225]] ) 4226end 4227 4228api . nvim_input_mouse ( 'wheel' , 'down' , '' , 0 , 6 , 15 ) 4229if multigrid then 4230screen : expect ( { 4231grid =[[ 4232## grid 1 4233[5:----------------------------------------]|*3 4234{3:[No Name] [+] }| 4235[2:----------------------------------------]|*2 4236{2:[No Name] [+] }| 4237[3:----------------------------------------]| 4238## grid 2 4239word | 4240{1:~ }| 4241## grid 3 4242{5:-- INSERT --} | 4243## grid 4 4244{12:word }| 4245{n:choice }| 4246{n:text }| 4247{n:thing }| 4248## grid 5 4249xx | 4250word^ | 4251{1:~ }| 4252]] , 4253float_pos ={ [ 4 ] ={ - 1 , 'NW' , 5 , 2 , 0 , false , 100 , 1 , 2 , 0 } } , 4254} ) 4255else 4256screen : expect ( [[ 4257xx | 4258word^ | 4259{12:word }{1: }| 4260{n:choice }{3: }| 4261{n:text } | 4262{n:thing }{1: }| 4263{2:[No Name] [+] }| 4264{5:-- INSERT --} | 4265]] ) 4266end 4267end ) 4268 4269if not multigrid then 4270it ( 'with kind, menu and abbr attributes' , function () 4271screen : try_resize ( 40 , 8 ) 4272feed ( 'ixx ' ) 4273fn . complete ( 4 , { 4274{ word ='wordey' , kind ='x' , menu ='extrainfo' } , 4275'thing' , 4276{ word ='secret' , abbr ='sneaky' , menu ='bar' } , 4277} ) 4278screen : expect ( [[ 4279xx wordey^ | 4280{1:~ }{12: wordey x extrainfo }{1: }| 4281{1:~ }{n: thing }{1: }| 4282{1:~ }{n: sneaky bar }{1: }| 4283{1:~ }|*3 4284{5:-- INSERT --} | 4285]] ) 4286 4287feed ( '<c-p>' ) 4288screen : expect ( [[ 4289xx ^ | 4290{1:~ }{n: wordey x extrainfo }{1: }| 4291{1:~ }{n: thing }{1: }| 4292{1:~ }{n: sneaky bar }{1: }| 4293{1:~ }|*3 4294{5:-- INSERT --} | 4295]] ) 4296 4297feed ( '<c-p>' ) 4298screen : expect ( [[ 4299xx secret^ | 4300{1:~ }{n: wordey x extrainfo }{1: }| 4301{1:~ }{n: thing }{1: }| 4302{1:~ }{12: sneaky bar }{1: }| 4303{1:~ }|*3 4304{5:-- INSERT --} | 4305]] ) 4306 4307feed ( '<esc>' ) 4308screen : expect ( [[ 4309xx secre^t | 4310{1:~ }|*6 4311| 4312]] ) 4313end ) 4314 4315it ( 'wildoptions=pum' , function () 4316screen : try_resize ( 32 , 10 ) 4317command ( 'set wildmenu' ) 4318command ( 'set wildoptions=pum' ) 4319command ( 'set shellslash' ) 4320command ( 'cd test/functional/fixtures/wildpum' ) 4321 4322feed ( ':sign ' ) 4323screen : expect ( [[ 4324| 4325{1:~ }|*8 4326:sign ^ | 4327]] ) 4328 4329feed ( '<Tab>' ) 4330screen : expect ( [[ 4331| 4332{1:~ }|*2 4333{1:~ }{12: define }{1: }| 4334{1:~ }{n: jump }{1: }| 4335{1:~ }{n: list }{1: }| 4336{1:~ }{n: place }{1: }| 4337{1:~ }{n: undefine }{1: }| 4338{1:~ }{n: unplace }{1: }| 4339:sign define^ | 4340]] ) 4341 4342feed ( '<Right><Right>' ) 4343screen : expect ( [[ 4344| 4345{1:~ }|*2 4346{1:~ }{n: define }{1: }| 4347{1:~ }{n: jump }{1: }| 4348{1:~ }{12: list }{1: }| 4349{1:~ }{n: place }{1: }| 4350{1:~ }{n: undefine }{1: }| 4351{1:~ }{n: unplace }{1: }| 4352:sign list^ | 4353]] ) 4354 4355feed ( '<C-N>' ) 4356screen : expect ( [[ 4357| 4358{1:~ }|*2 4359{1:~ }{n: define }{1: }| 4360{1:~ }{n: jump }{1: }| 4361{1:~ }{n: list }{1: }| 4362{1:~ }{12: place }{1: }| 4363{1:~ }{n: undefine }{1: }| 4364{1:~ }{n: unplace }{1: }| 4365:sign place^ | 4366]] ) 4367 4368feed ( '<C-P>' ) 4369screen : expect ( [[ 4370| 4371{1:~ }|*2 4372{1:~ }{n: define }{1: }| 4373{1:~ }{n: jump }{1: }| 4374{1:~ }{12: list }{1: }| 4375{1:~ }{n: place }{1: }| 4376{1:~ }{n: undefine }{1: }| 4377{1:~ }{n: unplace }{1: }| 4378:sign list^ | 4379]] ) 4380 4381feed ( '<Left>' ) 4382screen : expect ( [[ 4383| 4384{1:~ }|*2 4385{1:~ }{n: define }{1: }| 4386{1:~ }{12: jump }{1: }| 4387{1:~ }{n: list }{1: }| 4388{1:~ }{n: place }{1: }| 4389{1:~ }{n: undefine }{1: }| 4390{1:~ }{n: unplace }{1: }| 4391:sign jump^ | 4392]] ) 4393 4394-- pressing <C-E> should end completion and go back to the original match 4395feed ( '<C-E>' ) 4396screen : expect ( [[ 4397| 4398{1:~ }|*8 4399:sign ^ | 4400]] ) 4401 4402-- pressing <C-Y> should select the current match and end completion 4403feed ( '<Tab><C-P><C-P><C-Y>' ) 4404screen : expect ( [[ 4405| 4406{1:~ }|*8 4407:sign unplace^ | 4408]] ) 4409 4410-- showing popup menu in different columns in the cmdline 4411feed ( '<C-U>sign define <Tab>' ) 4412screen : expect ( [[ 4413| 4414{1:~ }| 4415{1:~ }{12: culhl= }{1: }| 4416{1:~ }{n: icon= }{1: }| 4417{1:~ }{n: linehl= }{1: }| 4418{1:~ }{n: numhl= }{1: }| 4419{1:~ }{n: priority= }{1: }| 4420{1:~ }{n: text= }{1: }| 4421{1:~ }{n: texthl= }{1: }| 4422:sign define culhl=^ | 4423]] ) 4424 4425feed ( '<Space><Tab>' ) 4426screen : expect ( [[ 4427| 4428{1:~ }| 4429{1:~ }{12: culhl= }| 4430{1:~ }{n: icon= }| 4431{1:~ }{n: linehl= }| 4432{1:~ }{n: numhl= }| 4433{1:~ }{n: priority= }| 4434{1:~ }{n: text= }| 4435{1:~ }{n: texthl= }| 4436:sign define culhl= culhl=^ | 4437]] ) 4438 4439feed ( '<C-U>e Xnamedi<Tab><Tab>' ) 4440screen : expect ( [[ 4441| 4442{1:~ }|*6 4443{1:~ }{12: XdirA/ }{1: }| 4444{1:~ }{n: XfileA }{1: }| 4445:e Xnamedir/XdirA/^ | 4446]] ) 4447 4448-- Pressing <Down> on a directory name should go into that directory 4449feed ( '<Down>' ) 4450screen : expect ( [[ 4451| 4452{1:~ }|*6 4453{1:~ }{12: XdirB/ }| 4454{1:~ }{n: XfileB }| 4455:e Xnamedir/XdirA/XdirB/^ | 4456]] ) 4457 4458-- Pressing <Up> on a directory name should go to the parent directory 4459feed ( '<Up>' ) 4460screen : expect ( [[ 4461| 4462{1:~ }|*6 4463{1:~ }{12: XdirA/ }{1: }| 4464{1:~ }{n: XfileA }{1: }| 4465:e Xnamedir/XdirA/^ | 4466]] ) 4467 4468-- Pressing <C-A> when the popup menu is displayed should list all the 4469-- matches and remove the popup menu 4470feed ( ':<C-U>sign <Tab><C-A>' ) 4471screen : expect ( [[ 4472| 4473{1:~ }|*6 4474{3: }| 4475:sign define jump list place und| 4476efine unplace^ | 4477]] ) 4478 4479-- Pressing <Left> after that should move the cursor 4480feed ( '<Left>' ) 4481screen : expect ( [[ 4482| 4483{1:~ }|*6 4484{3: }| 4485:sign define jump list place und| 4486efine unplac^e | 4487]] ) 4488feed ( '<End>' ) 4489 4490-- Pressing <C-D> when the popup menu is displayed should remove the popup 4491-- menu 4492feed ( '<C-U>sign <Tab><C-D>' ) 4493screen : expect ( [[ 4494| 4495{1:~ }|*5 4496{3: }| 4497:sign define | 4498define | 4499:sign define^ | 4500]] ) 4501 4502-- Pressing <S-Tab> should open the popup menu with the last entry selected 4503feed ( '<C-U><CR>:sign <S-Tab><C-P>' ) 4504screen : expect ( [[ 4505| 4506{1:~ }|*2 4507{1:~ }{n: define }{1: }| 4508{1:~ }{n: jump }{1: }| 4509{1:~ }{n: list }{1: }| 4510{1:~ }{n: place }{1: }| 4511{1:~ }{12: undefine }{1: }| 4512{1:~ }{n: unplace }{1: }| 4513:sign undefine^ | 4514]] ) 4515 4516-- Pressing <Esc> should close the popup menu and cancel the cmd line 4517feed ( '<C-U><CR>:sign <Tab><Esc>' ) 4518screen : expect ( [[ 4519^ | 4520{1:~ }|*8 4521| 4522]] ) 4523 4524-- Typing a character when the popup is open, should close the popup 4525feed ( ':sign <Tab>x' ) 4526screen : expect ( [[ 4527| 4528{1:~ }|*8 4529:sign definex^ | 4530]] ) 4531 4532-- When the popup is open, entering cmdwin should close the popup. 4533feed ( '<C-U>sign <Tab><C-F>' ) 4534t . retry ( nil , 2000 , function () 4535eq ( ':' , n . fn . getcmdwintype ()) 4536end ) 4537eq ( 0 , n . fn . pumvisible ()) 4538feed ( ':q<CR>' ) 4539 4540-- After the last popup menu item, <C-N> should show the original string 4541feed ( ':sign u<Tab><C-N><C-N>' ) 4542screen : expect ( [[ 4543| 4544{1:~ }|*6 4545{1:~ }{n: undefine }{1: }| 4546{1:~ }{n: unplace }{1: }| 4547:sign u^ | 4548]] ) 4549 4550-- Use the popup menu for the command name 4551feed ( '<C-U>bu<Tab>' ) 4552screen : expect ( [[ 4553| 4554{1:~ }|*4 4555{12: bufdo }{1: }| 4556{n: buffer }{1: }| 4557{n: buffers }{1: }| 4558{n: bunload }{1: }| 4559:bufdo^ | 4560]] ) 4561 4562-- Pressing <BS> should remove the popup menu and erase the last character 4563feed ( '<C-E><C-U>sign <Tab><BS>' ) 4564screen : expect ( [[ 4565| 4566{1:~ }|*8 4567:sign defin^ | 4568]] ) 4569 4570-- Pressing <C-W> should remove the popup menu and erase the previous word 4571feed ( '<C-E><C-U>sign <Tab><C-W>' ) 4572screen : expect ( [[ 4573| 4574{1:~ }|*8 4575:sign ^ | 4576]] ) 4577 4578-- Pressing <C-U> should remove the popup menu and erase the entire line 4579feed ( '<C-E><C-U>sign <Tab><C-U>' ) 4580screen : expect ( [[ 4581| 4582{1:~ }|*8 4583:^ | 4584]] ) 4585 4586-- Using <C-E> to cancel the popup menu and then pressing <Up> should recall 4587-- the cmdline from history 4588feed ( 'sign xyz<Esc>:sign <Tab><C-E><Up>' ) 4589screen : expect ( [[ 4590| 4591{1:~ }|*8 4592:sign xyz^ | 4593]] ) 4594 4595feed ( '<esc>' ) 4596 4597-- Check that when "longest" produces no result, "list" works 4598command ( 'set wildmode=longest,list' ) 4599feed ( ':cn<Tab>' ) 4600screen : expect ( [[ 4601| 4602{1:~ }|*3 4603{3: }| 4604:cn | 4605cnewer cnoreabbrev | 4606cnext cnoremap | 4607cnfile cnoremenu | 4608:cn^ | 4609]] ) 4610feed ( '<Tab>' ) 4611screen : expect_unchanged () 4612feed ( 's' ) 4613screen : expect ( [[ 4614| 4615{1:~ }|*3 4616{3: }| 4617:cn | 4618cnewer cnoreabbrev | 4619cnext cnoremap | 4620cnfile cnoremenu | 4621:cns^ | 4622]] ) 4623 4624feed ( '<esc>' ) 4625command ( 'set wildmode=full' ) 4626 4627-- Tests a directory name contained full-width characters. 4628feed ( ':e あいう/<Tab>' ) 4629screen : expect ( [[ 4630| 4631{1:~ }|*5 4632{1:~ }{12: 123 }{1: }| 4633{1:~ }{n: abc }{1: }| 4634{1:~ }{n: xyz }{1: }| 4635:e あいう/123^ | 4636]] ) 4637feed ( '<Esc>' ) 4638 4639-- Pressing <PageDown> should scroll the menu downward 4640feed ( ':sign <Tab><PageDown>' ) 4641screen : expect ( [[ 4642| 4643{1:~ }|*2 4644{1:~ }{n: define }{1: }| 4645{1:~ }{n: jump }{1: }| 4646{1:~ }{n: list }{1: }| 4647{1:~ }{n: place }{1: }| 4648{1:~ }{12: undefine }{1: }| 4649{1:~ }{n: unplace }{1: }| 4650:sign undefine^ | 4651]] ) 4652feed ( '<PageDown>' ) 4653screen : expect ( [[ 4654| 4655{1:~ }|*2 4656{1:~ }{n: define }{1: }| 4657{1:~ }{n: jump }{1: }| 4658{1:~ }{n: list }{1: }| 4659{1:~ }{n: place }{1: }| 4660{1:~ }{n: undefine }{1: }| 4661{1:~ }{12: unplace }{1: }| 4662:sign unplace^ | 4663]] ) 4664feed ( '<PageDown>' ) 4665screen : expect ( [[ 4666| 4667{1:~ }|*2 4668{1:~ }{n: define }{1: }| 4669{1:~ }{n: jump }{1: }| 4670{1:~ }{n: list }{1: }| 4671{1:~ }{n: place }{1: }| 4672{1:~ }{n: undefine }{1: }| 4673{1:~ }{n: unplace }{1: }| 4674:sign ^ | 4675]] ) 4676feed ( '<PageDown>' ) 4677screen : expect ( [[ 4678| 4679{1:~ }|*2 4680{1:~ }{12: define }{1: }| 4681{1:~ }{n: jump }{1: }| 4682{1:~ }{n: list }{1: }| 4683{1:~ }{n: place }{1: }| 4684{1:~ }{n: undefine }{1: }| 4685{1:~ }{n: unplace }{1: }| 4686:sign define^ | 4687]] ) 4688feed ( '<C-U>sign <Tab><Right><Right><PageDown>' ) 4689screen : expect ( [[ 4690| 4691{1:~ }|*2 4692{1:~ }{n: define }{1: }| 4693{1:~ }{n: jump }{1: }| 4694{1:~ }{n: list }{1: }| 4695{1:~ }{n: place }{1: }| 4696{1:~ }{n: undefine }{1: }| 4697{1:~ }{12: unplace }{1: }| 4698:sign unplace^ | 4699]] ) 4700 4701-- Pressing <PageUp> should scroll the menu upward 4702feed ( '<C-U>sign <Tab><PageUp>' ) 4703screen : expect ( [[ 4704| 4705{1:~ }|*2 4706{1:~ }{n: define }{1: }| 4707{1:~ }{n: jump }{1: }| 4708{1:~ }{n: list }{1: }| 4709{1:~ }{n: place }{1: }| 4710{1:~ }{n: undefine }{1: }| 4711{1:~ }{n: unplace }{1: }| 4712:sign ^ | 4713]] ) 4714feed ( '<PageUp>' ) 4715screen : expect ( [[ 4716| 4717{1:~ }|*2 4718{1:~ }{n: define }{1: }| 4719{1:~ }{n: jump }{1: }| 4720{1:~ }{n: list }{1: }| 4721{1:~ }{n: place }{1: }| 4722{1:~ }{n: undefine }{1: }| 4723{1:~ }{12: unplace }{1: }| 4724:sign unplace^ | 4725]] ) 4726feed ( '<PageUp>' ) 4727screen : expect ( [[ 4728| 4729{1:~ }|*2 4730{1:~ }{n: define }{1: }| 4731{1:~ }{12: jump }{1: }| 4732{1:~ }{n: list }{1: }| 4733{1:~ }{n: place }{1: }| 4734{1:~ }{n: undefine }{1: }| 4735{1:~ }{n: unplace }{1: }| 4736:sign jump^ | 4737]] ) 4738feed ( '<PageUp>' ) 4739screen : expect ( [[ 4740| 4741{1:~ }|*2 4742{1:~ }{12: define }{1: }| 4743{1:~ }{n: jump }{1: }| 4744{1:~ }{n: list }{1: }| 4745{1:~ }{n: place }{1: }| 4746{1:~ }{n: undefine }{1: }| 4747{1:~ }{n: unplace }{1: }| 4748:sign define^ | 4749]] ) 4750 4751-- pressing <C-E> to end completion should work in middle of the line too 4752feed ( '<Esc>:set wildchazz<Left><Left><Tab>' ) 4753screen : expect ( [[ 4754| 4755{1:~ }|*6 4756{1:~ }{12: wildchar }{1: }| 4757{1:~ }{n: wildcharm }{1: }| 4758:set wildchar^zz | 4759]] ) 4760feed ( '<C-E>' ) 4761screen : expect ( [[ 4762| 4763{1:~ }|*8 4764:set wildcha^zz | 4765]] ) 4766 4767-- pressing <C-Y> should select the current match and end completion 4768feed ( '<Esc>:set wildchazz<Left><Left><Tab><C-Y>' ) 4769screen : expect ( [[ 4770| 4771{1:~ }|*8 4772:set wildchar^zz | 4773]] ) 4774 4775feed ( '<Esc>' ) 4776 4777-- "longest:list" shows list whether it finds a candidate or not 4778command ( 'set wildmode=longest:list,full wildoptions=' ) 4779feed ( ':cn<Tab>' ) 4780screen : expect ( [[ 4781| 4782{1:~ }|*3 4783{3: }| 4784:cn | 4785cnewer cnoreabbrev | 4786cnext cnoremap | 4787cnfile cnoremenu | 4788:cn^ | 4789]] ) 4790feed ( '<Tab>' ) 4791screen : expect ( [[ 4792| 4793{1:~ }|*2 4794{3: }| 4795:cn | 4796cnewer cnoreabbrev | 4797cnext cnoremap | 4798cnfile cnoremenu | 4799{113:cnewer}{3: cnext cnfile > }| 4800:cnewer^ | 4801]] ) 4802feed ( '<Esc>:sign u<Tab>' ) 4803screen : expect ( [[ 4804| 4805{1:~ }|*5 4806{3: }| 4807:sign un | 4808undefine unplace | 4809:sign un^ | 4810]] ) 4811 4812-- "longest:full" shows wildmenu whether it finds a candidate or not; 4813-- item not selected 4814feed ( '<Esc>' ) 4815command ( 'set wildmode=longest:full,full' ) 4816feed ( ':sign u<Tab>' ) 4817screen : expect ( [[ 4818| 4819{1:~ }|*7 4820{3:undefine unplace }| 4821:sign un^ | 4822]] ) 4823feed ( '<Tab>' ) 4824screen : expect ( [[ 4825| 4826{1:~ }|*7 4827{113:undefine}{3: unplace }| 4828:sign undefine^ | 4829]] ) 4830 4831feed ( '<Esc>:cn<Tab>' ) 4832screen : expect ( [[ 4833| 4834{1:~ }|*7 4835{3:cnewer cnext cnfile > }| 4836:cn^ | 4837]] ) 4838feed ( '<Tab>' ) 4839screen : expect ( [[ 4840| 4841{1:~ }|*7 4842{113:cnewer}{3: cnext cnfile > }| 4843:cnewer^ | 4844]] ) 4845 4846-- If "longest,full" finds a candidate, wildmenu is not shown 4847feed ( '<Esc>' ) 4848command ( 'set wildmode=longest,full' ) 4849feed ( ':sign u<Tab>' ) 4850screen : expect ( [[ 4851| 4852{1:~ }|*8 4853:sign un^ | 4854]] ) 4855-- Subsequent wildchar shows wildmenu 4856feed ( '<Tab>' ) 4857screen : expect ( [[ 4858| 4859{1:~ }|*7 4860{113:undefine}{3: unplace }| 4861:sign undefine^ | 4862]] ) 4863 4864-- 'longest' does not find candidate, and displays menu without selecting item 4865feed ( '<Esc>' ) 4866command ( 'set wildmode=longest,noselect' ) 4867feed ( ':cn<Tab>' ) 4868screen : expect ( [[ 4869| 4870{1:~ }|*7 4871{3:cnewer cnext cnfile > }| 4872:cn^ | 4873]] ) 4874 4875command ( 'set wildmode& wildoptions=pum' ) 4876 4877feed ( '<C-U><Esc>' ) 4878 4879-- check positioning with multibyte char in pattern 4880command ( 'e långfile1' ) 4881command ( 'sp långfile2' ) 4882feed ( ':b lå<tab>' ) 4883screen : expect ( [[ 4884| 4885{1:~ }|*3 4886{3:långfile2 }| 4887| 4888{1:~ }| 4889{1:~ }{12: långfile1 }{1: }| 4890{2:lå}{n: långfile2 }{2: }| 4891:b långfile1^ | 4892]] ) 4893 4894-- check doesn't crash on screen resize 4895screen : try_resize ( 20 , 6 ) 4896screen : expect ( [[ 4897| 4898{1:~ }| 4899{3:långfile2 }| 4900{12: långfile1 } | 4901{2:lå}{n: långfile2 }{2: }| 4902:b långfile1^ | 4903]] ) 4904 4905screen : try_resize ( 50 , 15 ) 4906screen : expect ( [[ 4907| 4908{1:~ }| 4909{3:långfile2 }| 4910| 4911{1:~ }|*8 4912{1:~ }{12: långfile1 }{1: }| 4913{2:lå}{n: långfile2 }{2: }| 4914:b långfile1^ | 4915]] ) 4916 4917-- position is calculated correctly with "longest" 4918feed ( '<esc>' ) 4919command ( 'set wildmode=longest:full,full' ) 4920feed ( ':b lå<tab>' ) 4921screen : expect ( [[ 4922| 4923{1:~ }| 4924{3:långfile2 }| 4925| 4926{1:~ }|*8 4927{1:~ }{n: långfile1 }{1: }| 4928{2:lå}{n: långfile2 }{2: }| 4929:b långfile^ | 4930]] ) 4931 4932feed ( '<esc>' ) 4933command ( '%bwipe' ) 4934command ( 'set wildmode=full' ) 4935 4936-- special case: when patterns ends with "/", show menu items aligned 4937-- after the "/" 4938feed ( ':e compdir/<tab>' ) 4939screen : expect ( [[ 4940| 4941{1:~ }|*11 4942{1:~ }{12: file1 }{1: }| 4943{1:~ }{n: file2 }{1: }| 4944:e compdir/file1^ | 4945]] ) 4946 4947-- position is correct when expanding environment variable #20348 4948command ( 'cd ..' ) 4949fn . setenv ( 'XNDIR' , 'wildpum/Xnamedir' ) 4950feed ( '<C-U>e $XNDIR/<Tab>' ) 4951screen : expect ( [[ 4952| 4953{1:~ }|*11 4954{1:~ }{12: XdirA/ }{1: }| 4955{1:~ }{n: XfileA }{1: }| 4956:e wildpum/Xnamedir/XdirA/^ | 4957]] ) 4958end ) 4959end 4960 4961it ( 'wildoptions=pum with scrolled messages' , function () 4962screen : try_resize ( 40 , 10 ) 4963command ( 'set wildmenu' ) 4964command ( 'set wildoptions=pum' ) 4965 4966feed ( ':echoerr "fail"|echoerr "error"<cr>' ) 4967if multigrid then 4968screen : expect ( [[ 4969## grid 1 4970[2:----------------------------------------]|*7 4971[3:----------------------------------------]|*3 4972## grid 2 4973| 4974{1:~ }|*8 4975## grid 3 4976{9:fail} | 4977{9:error} | 4978{6:Press ENTER or type command to continue}^ | 4979]] ) 4980else 4981screen : expect ( [[ 4982| 4983{1:~ }|*5 4984{3: }| 4985{9:fail} | 4986{9:error} | 4987{6:Press ENTER or type command to continue}^ | 4988]] ) 4989end 4990 4991feed ( ':sign <tab>' ) 4992if multigrid then 4993screen : expect ( { 4994grid =[[ 4995## grid 1 4996[2:----------------------------------------]|*7 4997[3:----------------------------------------]|*3 4998## grid 2 4999| 5000{1:~ }|*8 5001## grid 3 5002{9:fail} | 5003{9:error} | 5004:sign define^ | 5005## grid 4 5006{12: define }| 5007{n: jump }| 5008{n: list }| 5009{n: place }| 5010{n: undefine }| 5011{n: unplace }| 5012]] , 5013float_pos ={ [ 4 ] ={ - 1 , 'SW' , 1 , 9 , 5 , false , 250 , 2 , 3 , 5 } } , 5014} ) 5015else 5016screen : expect ( [[ 5017| 5018{1:~ }|*2 5019{1:~ }{12: define }{1: }| 5020{1:~ }{n: jump }{1: }| 5021{1:~ }{n: list }{1: }| 5022{3: }{n: place }{3: }| 5023{9:fail} {n: undefine } | 5024{9:error}{n: unplace } | 5025:sign define^ | 5026]] ) 5027end 5028 5029feed ( 'd' ) 5030if multigrid then 5031screen : expect ( [[ 5032## grid 1 5033[2:----------------------------------------]|*7 5034[3:----------------------------------------]|*3 5035## grid 2 5036| 5037{1:~ }|*8 5038## grid 3 5039{9:fail} | 5040{9:error} | 5041:sign defined^ | 5042]] ) 5043else 5044screen : expect ( [[ 5045| 5046{1:~ }|*5 5047{3: }| 5048{9:fail} | 5049{9:error} | 5050:sign defined^ | 5051]] ) 5052end 5053end ) 5054 5055if not multigrid then 5056it ( 'wildoptions=pum and wildmode=longest,full #11622' , function () 5057screen : try_resize ( 30 , 8 ) 5058command ( 'set wildmenu' ) 5059command ( 'set wildoptions=pum' ) 5060command ( 'set wildmode=longest,full' ) 5061 5062-- With 'wildmode' set to 'longest,full', completing a match should display 5063-- the longest match, the wildmenu should not be displayed. 5064feed ( ':sign u<Tab>' ) 5065screen : expect ( [[ 5066| 5067{1:~ }|*6 5068:sign un^ | 5069]] ) 5070eq ( 0 , fn . wildmenumode ()) 5071 5072-- pressing <Tab> should display the wildmenu 5073feed ( '<Tab>' ) 5074local s1 =[[ 5075| 5076{1:~ }|*4 5077{1:~ }{12: undefine }{1: }| 5078{1:~ }{n: unplace }{1: }| 5079:sign undefine^ | 5080]] 5081screen : expect ( s1 ) 5082eq ( 1 , fn . wildmenumode ()) 5083 5084-- pressing <Tab> second time should select the next entry in the menu 5085feed ( '<Tab>' ) 5086local s2 =[[ 5087| 5088{1:~ }|*4 5089{1:~ }{n: undefine }{1: }| 5090{1:~ }{12: unplace }{1: }| 5091:sign unplace^ | 5092]] 5093screen : expect ( s2 ) 5094eq ( 1 , fn . wildmenumode ()) 5095 5096-- If "longest" finds no candidate in "longest,full", "full" is used 5097feed ( '<Esc>' ) 5098command ( 'set wildmode=longest,full' ) 5099command ( 'set wildoptions=pum' ) 5100feed ( ':sign un<Tab>' ) 5101screen : expect ( s1 ) 5102feed ( '<Tab>' ) 5103screen : expect ( s2 ) 5104 5105-- Similarly for "longest,noselect:full" 5106feed ( '<Esc>' ) 5107command ( 'set wildmode=longest,noselect:full' ) 5108feed ( ':sign un<Tab>' ) 5109screen : expect ( [[ 5110| 5111{1:~ }|*4 5112{1:~ }{n: undefine }{1: }| 5113{1:~ }{n: unplace }{1: }| 5114:sign un^ | 5115]] ) 5116feed ( '<Tab>' ) 5117screen : expect ( s1 ) 5118feed ( '<Tab>' ) 5119screen : expect ( s2 ) 5120end ) 5121 5122it ( 'wildoptions=pum with a wrapped line in buffer vim-patch:8.2.4655' , function () 5123screen : try_resize ( 32 , 10 ) 5124api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { ( 'a' ): rep ( 100 ) } ) 5125command ( 'set wildoptions+=pum' ) 5126feed ( '$' ) 5127feed ( ':sign <Tab>' ) 5128screen : expect ( [[ 5129aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*3 5130aaaa {12: define } | 5131{1:~ }{n: jump }{1: }| 5132{1:~ }{n: list }{1: }| 5133{1:~ }{n: place }{1: }| 5134{1:~ }{n: undefine }{1: }| 5135{1:~ }{n: unplace }{1: }| 5136:sign define^ | 5137]] ) 5138end ) 5139 5140-- oldtest: Test_wildmenu_pum_odd_wildchar() 5141it ( 'wildoptions=pum with odd wildchar' , function () 5142screen : try_resize ( 30 , 10 ) 5143-- Test odd wildchar interactions with pum. Make sure they behave properly 5144-- and don't lead to memory corruption due to improperly cleaned up memory. 5145exec ( [[ 5146set wildoptions=pum 5147set wildchar=<C-E> 5148]] ) 5149 5150feed ( ':sign <C-E>' ) 5151screen : expect ( [[ 5152| 5153{1:~ }|*2 5154{1:~ }{12: define }{1: }| 5155{1:~ }{n: jump }{1: }| 5156{1:~ }{n: list }{1: }| 5157{1:~ }{n: place }{1: }| 5158{1:~ }{n: undefine }{1: }| 5159{1:~ }{n: unplace }{1: }| 5160:sign define^ | 5161]] ) 5162 5163-- <C-E> being a wildchar takes priority over its original functionality 5164feed ( '<C-E>' ) 5165screen : expect ( [[ 5166| 5167{1:~ }|*2 5168{1:~ }{n: define }{1: }| 5169{1:~ }{12: jump }{1: }| 5170{1:~ }{n: list }{1: }| 5171{1:~ }{n: place }{1: }| 5172{1:~ }{n: undefine }{1: }| 5173{1:~ }{n: unplace }{1: }| 5174:sign jump^ | 5175]] ) 5176 5177feed ( '<Esc>' ) 5178screen : expect ( [[ 5179^ | 5180{1:~ }|*8 5181| 5182]] ) 5183 5184-- Escape key can be wildchar too. Double-<Esc> is hard-coded to escape 5185-- command-line, and we need to make sure to clean up properly. 5186command ( 'set wildchar=<Esc>' ) 5187feed ( ':sign <Esc>' ) 5188screen : expect ( [[ 5189| 5190{1:~ }|*2 5191{1:~ }{12: define }{1: }| 5192{1:~ }{n: jump }{1: }| 5193{1:~ }{n: list }{1: }| 5194{1:~ }{n: place }{1: }| 5195{1:~ }{n: undefine }{1: }| 5196{1:~ }{n: unplace }{1: }| 5197:sign define^ | 5198]] ) 5199 5200feed ( '<Esc>' ) 5201screen : expect ( [[ 5202^ | 5203{1:~ }|*8 5204| 5205]] ) 5206 5207-- <C-\> can also be wildchar. <C-\><C-N> however will still escape cmdline 5208-- and we again need to make sure we clean up properly. 5209command ( [[set wildchar=<C-\>]] ) 5210feed ( [[:sign <C-\><C-\>]] ) 5211screen : expect ( [[ 5212| 5213{1:~ }|*2 5214{1:~ }{12: define }{1: }| 5215{1:~ }{n: jump }{1: }| 5216{1:~ }{n: list }{1: }| 5217{1:~ }{n: place }{1: }| 5218{1:~ }{n: undefine }{1: }| 5219{1:~ }{n: unplace }{1: }| 5220:sign define^ | 5221]] ) 5222 5223feed ( '<C-N>' ) 5224screen : expect ( [[ 5225^ | 5226{1:~ }|*8 5227| 5228]] ) 5229end ) 5230 5231-- oldtest: Test_wildmenu_pum_hl_match() 5232it ( 'highlighting matched text in cmdline pum' , function () 5233exec ( [[ 5234set wildoptions=pum,fuzzy 5235hi PmenuMatchSel guifg=Blue guibg=Grey 5236hi PmenuMatch guifg=Blue guibg=Plum1 5237]] ) 5238 5239feed ( ':sign plc<Tab>' ) 5240screen : expect ( [[ 5241| 5242{1:~ }|*16 5243{1:~ }{12: }{ms:pl}{12:a}{ms:c}{12:e }{1: }| 5244{1:~ }{n: un}{mn:pl}{n:a}{mn:c}{n:e }{1: }| 5245:sign place^ | 5246]] ) 5247feed ( '<Tab>' ) 5248screen : expect ( [[ 5249| 5250{1:~ }|*16 5251{1:~ }{n: }{mn:pl}{n:a}{mn:c}{n:e }{1: }| 5252{1:~ }{12: un}{ms:pl}{12:a}{ms:c}{12:e }{1: }| 5253:sign unplace^ | 5254]] ) 5255feed ( '<Tab>' ) 5256screen : expect ( [[ 5257| 5258{1:~ }|*16 5259{1:~ }{n: }{mn:pl}{n:a}{mn:c}{n:e }{1: }| 5260{1:~ }{n: un}{mn:pl}{n:a}{mn:c}{n:e }{1: }| 5261:sign plc^ | 5262]] ) 5263feed ( '<Esc>' ) 5264command ( 'set wildoptions-=fuzzy' ) 5265feed ( ':sign un<Tab>' ) 5266screen : expect ( [[ 5267| 5268{1:~ }|*16 5269{1:~ }{12: }{ms:un}{12:define }{1: }| 5270{1:~ }{n: }{mn:un}{n:place }{1: }| 5271:sign undefine^ | 5272]] ) 5273feed ( '<Tab>' ) 5274screen : expect ( [[ 5275| 5276{1:~ }|*16 5277{1:~ }{n: }{mn:un}{n:define }{1: }| 5278{1:~ }{12: }{ms:un}{12:place }{1: }| 5279:sign unplace^ | 5280]] ) 5281feed ( '<Tab>' ) 5282screen : expect ( [[ 5283| 5284{1:~ }|*16 5285{1:~ }{n: }{mn:un}{n:define }{1: }| 5286{1:~ }{n: }{mn:un}{n:place }{1: }| 5287:sign un^ | 5288]] ) 5289end ) 5290 5291-- oldtest: Test_wildmenu_pum_hl_nonfirst() 5292it ( 'highlight matched text in the middle in cmdline pum' , function () 5293exec ( [[ 5294set wildoptions=pum wildchar=<tab> wildmode=noselect,full 5295hi PmenuMatchSel guifg=Blue guibg=Grey 5296hi PmenuMatch guifg=Blue guibg=Plum1 5297func T(a, c, p) 5298return ["oneA", "o neBneB", "aoneC"] 5299endfunc 5300command -nargs=1 -complete=customlist,T MyCmd 5301]] ) 5302 5303feed ( ':MyCmd ne<tab>' ) 5304screen : expect ( [[ 5305| 5306{1:~ }|*15 5307{1:~ }{n: o}{mn:ne}{n:A }{1: }| 5308{1:~ }{n: o }{mn:ne}{n:BneB }{1: }| 5309{1:~ }{n: ao}{mn:ne}{n:C }{1: }| 5310:MyCmd ne^ | 5311]] ) 5312end ) 5313 5314-- oldtest: Test_pum_scroll_noselect() 5315it ( 'cmdline pum does not retain scroll position with "noselect"' , function () 5316screen : try_resize ( 32 , 10 ) 5317exec ( [[ 5318command! -nargs=* -complete=customlist,TestFn TestCmd echo 5319func TestFn(a, b, c) 5320return map(range(1, 50), 'printf("a%d", v:val)') 5321endfunc 5322set wildmode=noselect,full 5323set wildoptions=pum 5324set wildmenu 5325set noruler 5326]] ) 5327 5328feed ( ':TestCmd <tab>' .. ( '<c-n>' ): rep ( 20 )) 5329screen : expect ( [[ 5330{n: a15 }{12: } | 5331{1:~ }{n: a16 }{12: }{1: }| 5332{1:~ }{n: a17 }{12: }{1: }| 5333{1:~ }{n: a18 }{c: }{1: }| 5334{1:~ }{n: a19 }{12: }{1: }| 5335{1:~ }{12: a20 }{1: }| 5336{1:~ }{n: a21 }{12: }{1: }| 5337{1:~ }{n: a22 }{12: }{1: }| 5338{1:~ }{n: a23 }{12: }{1: }| 5339:TestCmd a20^ | 5340]] ) 5341 5342feed ( '<esc>:TestCmd <tab>' ) 5343screen : expect ( [[ 5344{n: a1 }{c: } | 5345{1:~ }{n: a2 }{12: }{1: }| 5346{1:~ }{n: a3 }{12: }{1: }| 5347{1:~ }{n: a4 }{12: }{1: }| 5348{1:~ }{n: a5 }{12: }{1: }| 5349{1:~ }{n: a6 }{12: }{1: }| 5350{1:~ }{n: a7 }{12: }{1: }| 5351{1:~ }{n: a8 }{12: }{1: }| 5352{1:~ }{n: a9 }{12: }{1: }| 5353:TestCmd ^ | 5354]] ) 5355end ) 5356 5357it ( 5358'cascading highlights for matched text (PmenuMatch, PmenuMatchSel) in cmdline pum' , 5359function () 5360exec ( [[ 5361set wildoptions=pum,fuzzy 5362hi Pmenu guifg=White guibg=Grey gui=underline,italic 5363hi PmenuSel guifg=Red gui=strikethrough 5364hi PmenuMatch guifg=Yellow guibg=Pink gui=bold 5365hi PmenuMatchSel guifg=Black guibg=White 5366]] ) 5367 5368feed ( ':sign plc<Tab>' ) 5369screen : expect ( [[ 5370| 5371{1:~ }|*16 5372{1:~ }{106: }{107:pl}{106:a}{107:c}{106:e }{1: }| 5373{1:~ }{108: un}{109:pl}{108:a}{109:c}{108:e }{1: }| 5374:sign place^ | 5375]] ) 5376end 5377) 5378end 5379 5380-- oldtest: Test_customlist_dict_completion_info_popup() 5381it ( 'cmdline pum with info popup from customlist' , function () 5382screen : try_resize ( 55 , 12 ) 5383exec ( [[ 5384func DictComp(A, L, P) 5385return [ 5386\ {'word': 'apple', 'kind': 'f', 'menu': 'fruit', 'info': 'A red fruit', 'abbr': '🍎'}, 5387\ {'word': 'banana', 'kind': 'f', 'menu': 'fruit', 'info': 'A yellow fruit', 'abbr': '🍌'}, 5388\ {'word': 'carrot', 'kind': 'v', 'menu': 'vegetable', 'info': 'An orange vegetable'}, 5389\ 'plain', 5390\ ] 5391endfunc 5392command -nargs=1 -complete=customlist,DictComp DictCmd echo <q-args> 5393set wildmenu wildoptions=pum completeopt=menu,popup 5394]] ) 5395 5396feed ( ':DictCmd <Tab>' ) 5397if multigrid then 5398screen : expect ( { 5399grid =[[ 5400## grid 1 5401[2:-------------------------------------------------------]|*11 5402[3:-------------------------------------------------------]| 5403## grid 2 5404| 5405{1:~ }|*10 5406## grid 3 5407:DictCmd apple^ | 5408## grid 4 5409{n:A red fruit}| 5410## grid 5 5411{12: 🍎 f fruit }| 5412{n: 🍌 f fruit }| 5413{n: carrot v vegetable }| 5414{n: plain }| 5415]] , 5416float_pos ={ 5417[ 5 ] ={ - 1 , 'SW' , 1 , 11 , 8 , false , 250 , 3 , 7 , 8 } , 5418[ 4 ] ={ 1001 , 'NW' , 1 , 7 , 28 , true , 50 , 1 , 7 , 28 } , 5419} , 5420} ) 5421else 5422screen : expect ( [[ 5423| 5424{1:~ }|*6 5425{1:~ }{12: 🍎 f fruit }{n:A red fruit}{1: }| 5426{1:~ }{n: 🍌 f fruit }{1: }| 5427{1:~ }{n: carrot v vegetable }{1: }| 5428{1:~ }{n: plain }{1: }| 5429:DictCmd apple^ | 5430]] ) 5431end 5432 5433feed ( '<Tab>' ) 5434if multigrid then 5435screen : expect ( { 5436grid =[[ 5437## grid 1 5438[2:-------------------------------------------------------]|*11 5439[3:-------------------------------------------------------]| 5440## grid 2 5441| 5442{1:~ }|*10 5443## grid 3 5444:DictCmd banana^ | 5445## grid 4 5446{n:A yellow fruit}| 5447## grid 5 5448{n: 🍎 f fruit }| 5449{12: 🍌 f fruit }| 5450{n: carrot v vegetable }| 5451{n: plain }| 5452]] , 5453float_pos ={ 5454[ 5 ] ={ - 1 , 'SW' , 1 , 11 , 8 , false , 250 , 3 , 7 , 8 } , 5455[ 4 ] ={ 1001 , 'NW' , 1 , 7 , 28 , true , 50 , 1 , 7 , 28 } , 5456} , 5457} ) 5458else 5459screen : expect ( [[ 5460| 5461{1:~ }|*6 5462{1:~ }{n: 🍎 f fruit A yellow fruit}{1: }| 5463{1:~ }{12: 🍌 f fruit }{1: }| 5464{1:~ }{n: carrot v vegetable }{1: }| 5465{1:~ }{n: plain }{1: }| 5466:DictCmd banana^ | 5467]] ) 5468end 5469 5470feed ( '<Tab>' ) 5471if multigrid then 5472screen : expect ( { 5473grid =[[ 5474## grid 1 5475[2:-------------------------------------------------------]|*11 5476[3:-------------------------------------------------------]| 5477## grid 2 5478| 5479{1:~ }|*10 5480## grid 3 5481:DictCmd carrot^ | 5482## grid 4 5483{n:An orange vegetable}| 5484## grid 5 5485{n: 🍎 f fruit }| 5486{n: 🍌 f fruit }| 5487{12: carrot v vegetable }| 5488{n: plain }| 5489]] , 5490float_pos ={ 5491[ 5 ] ={ - 1 , 'SW' , 1 , 11 , 8 , false , 250 , 3 , 7 , 8 } , 5492[ 4 ] ={ 1001 , 'NW' , 1 , 7 , 28 , true , 50 , 1 , 7 , 28 } , 5493} , 5494} ) 5495else 5496screen : expect ( [[ 5497| 5498{1:~ }|*6 5499{1:~ }{n: 🍎 f fruit An orange vegetable}{1: }| 5500{1:~ }{n: 🍌 f fruit }{1: }| 5501{1:~ }{12: carrot v vegetable }{1: }| 5502{1:~ }{n: plain }{1: }| 5503:DictCmd carrot^ | 5504]] ) 5505end 5506 5507feed ( '<Tab>' ) 5508if multigrid then 5509screen : expect ( { 5510grid =[[ 5511## grid 1 5512[2:-------------------------------------------------------]|*11 5513[3:-------------------------------------------------------]| 5514## grid 2 5515| 5516{1:~ }|*10 5517## grid 3 5518:DictCmd plain^ | 5519## grid 4 (hidden) 5520{n:An orange vegetable}| 5521## grid 5 5522{n: 🍎 f fruit }| 5523{n: 🍌 f fruit }| 5524{n: carrot v vegetable }| 5525{12: plain }| 5526]] , 5527float_pos ={ 5528[ 5 ] ={ - 1 , 'SW' , 1 , 11 , 8 , false , 250 , 2 , 7 , 8 } , 5529} , 5530} ) 5531else 5532screen : expect ( [[ 5533| 5534{1:~ }|*6 5535{1:~ }{n: 🍎 f fruit }{1: }| 5536{1:~ }{n: 🍌 f fruit }{1: }| 5537{1:~ }{n: carrot v vegetable }{1: }| 5538{1:~ }{12: plain }{1: }| 5539:DictCmd plain^ | 5540]] ) 5541end 5542 5543feed ( '<Tab>' ) 5544if multigrid then 5545screen : expect ( { 5546grid =[[ 5547## grid 1 5548[2:-------------------------------------------------------]|*11 5549[3:-------------------------------------------------------]| 5550## grid 2 5551| 5552{1:~ }|*10 5553## grid 3 5554:DictCmd ^ | 5555## grid 4 (hidden) 5556{n:An orange vegetable}| 5557## grid 5 5558{n: 🍎 f fruit }| 5559{n: 🍌 f fruit }| 5560{n: carrot v vegetable }| 5561{n: plain }| 5562]] , 5563float_pos ={ 5564[ 5 ] ={ - 1 , 'SW' , 1 , 11 , 8 , false , 250 , 2 , 7 , 8 } , 5565} , 5566} ) 5567else 5568screen : expect ( [[ 5569| 5570{1:~ }|*6 5571{1:~ }{n: 🍎 f fruit }{1: }| 5572{1:~ }{n: 🍌 f fruit }{1: }| 5573{1:~ }{n: carrot v vegetable }{1: }| 5574{1:~ }{n: plain }{1: }| 5575:DictCmd ^ | 5576]] ) 5577end 5578 5579feed ( '<Esc>' ) 5580 5581-- Tests for Insert mode i_CTRL-X_CTRL-V 5582feed ( 'iDictCmd <C-X><C-V>' ) 5583if multigrid then 5584screen : expect ( { 5585grid =[[ 5586## grid 1 5587[2:-------------------------------------------------------]|*11 5588[3:-------------------------------------------------------]| 5589## grid 2 5590DictCmd apple^ | 5591{1:~ }|*10 5592## grid 3 5593{5:-- Command-line completion (^V^N^P) }{6:match 1 of 4} | 5594## grid 5 5595{12: 🍎 f fruit }| 5596{n: 🍌 f fruit }| 5597{n: carrot v vegetable }| 5598{n: plain }| 5599## grid 6 5600{n:A red fruit}| 5601]] , 5602float_pos ={ 5603[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 7 , false , 100 , 2 , 1 , 7 } , 5604[ 6 ] ={ 1002 , 'NW' , 1 , 1 , 27 , true , 50 , 1 , 1 , 27 } , 5605} , 5606} ) 5607else 5608screen : expect ( [[ 5609DictCmd apple^ | 5610{1:~ }{12: 🍎 f fruit }{n:A red fruit}{1: }| 5611{1:~ }{n: 🍌 f fruit }{1: }| 5612{1:~ }{n: carrot v vegetable }{1: }| 5613{1:~ }{n: plain }{1: }| 5614{1:~ }|*6 5615{5:-- Command-line completion (^V^N^P) }{6:match 1 of 4} | 5616]] ) 5617end 5618 5619feed ( '<C-N>' ) 5620if multigrid then 5621screen : expect ( { 5622grid =[[ 5623## grid 1 5624[2:-------------------------------------------------------]|*11 5625[3:-------------------------------------------------------]| 5626## grid 2 5627DictCmd banana^ | 5628{1:~ }|*10 5629## grid 3 5630{5:-- Command-line completion (^V^N^P) }{6:match 2 of 4} | 5631## grid 5 5632{n: 🍎 f fruit }| 5633{12: 🍌 f fruit }| 5634{n: carrot v vegetable }| 5635{n: plain }| 5636## grid 6 5637{n:A yellow fruit}| 5638]] , 5639float_pos ={ 5640[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 7 , false , 100 , 2 , 1 , 7 } , 5641[ 6 ] ={ 1002 , 'NW' , 1 , 1 , 27 , true , 50 , 1 , 1 , 27 } , 5642} , 5643} ) 5644else 5645screen : expect ( [[ 5646DictCmd banana^ | 5647{1:~ }{n: 🍎 f fruit A yellow fruit}{1: }| 5648{1:~ }{12: 🍌 f fruit }{1: }| 5649{1:~ }{n: carrot v vegetable }{1: }| 5650{1:~ }{n: plain }{1: }| 5651{1:~ }|*6 5652{5:-- Command-line completion (^V^N^P) }{6:match 2 of 4} | 5653]] ) 5654end 5655 5656feed ( '<C-N>' ) 5657if multigrid then 5658screen : expect ( { 5659grid =[[ 5660## grid 1 5661[2:-------------------------------------------------------]|*11 5662[3:-------------------------------------------------------]| 5663## grid 2 5664DictCmd carrot^ | 5665{1:~ }|*10 5666## grid 3 5667{5:-- Command-line completion (^V^N^P) }{6:match 3 of 4} | 5668## grid 5 5669{n: 🍎 f fruit }| 5670{n: 🍌 f fruit }| 5671{12: carrot v vegetable }| 5672{n: plain }| 5673## grid 6 5674{n:An orange vegetable}| 5675]] , 5676float_pos ={ 5677[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 7 , false , 100 , 2 , 1 , 7 } , 5678[ 6 ] ={ 1002 , 'NW' , 1 , 1 , 27 , true , 50 , 1 , 1 , 27 } , 5679} , 5680} ) 5681else 5682screen : expect ( [[ 5683DictCmd carrot^ | 5684{1:~ }{n: 🍎 f fruit An orange vegetable}{1: }| 5685{1:~ }{n: 🍌 f fruit }{1: }| 5686{1:~ }{12: carrot v vegetable }{1: }| 5687{1:~ }{n: plain }{1: }| 5688{1:~ }|*6 5689{5:-- Command-line completion (^V^N^P) }{6:match 3 of 4} | 5690]] ) 5691end 5692 5693feed ( '<C-N>' ) 5694if multigrid then 5695screen : expect ( { 5696grid =[[ 5697## grid 1 5698[2:-------------------------------------------------------]|*11 5699[3:-------------------------------------------------------]| 5700## grid 2 5701DictCmd plain^ | 5702{1:~ }|*10 5703## grid 3 5704{5:-- Command-line completion (^V^N^P) }{6:match 4 of 4} | 5705## grid 5 5706{n: 🍎 f fruit }| 5707{n: 🍌 f fruit }| 5708{n: carrot v vegetable }| 5709{12: plain }| 5710## grid 6 (hidden) 5711{n:An orange vegetable}| 5712]] , 5713float_pos ={ 5714[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 7 , false , 100 , 1 , 1 , 7 } , 5715} , 5716} ) 5717else 5718screen : expect ( [[ 5719DictCmd plain^ | 5720{1:~ }{n: 🍎 f fruit }{1: }| 5721{1:~ }{n: 🍌 f fruit }{1: }| 5722{1:~ }{n: carrot v vegetable }{1: }| 5723{1:~ }{12: plain }{1: }| 5724{1:~ }|*6 5725{5:-- Command-line completion (^V^N^P) }{6:match 4 of 4} | 5726]] ) 5727end 5728 5729feed ( '<C-N>' ) 5730if multigrid then 5731screen : expect ( { 5732grid =[[ 5733## grid 1 5734[2:-------------------------------------------------------]|*11 5735[3:-------------------------------------------------------]| 5736## grid 2 5737DictCmd ^ | 5738{1:~ }|*10 5739## grid 3 5740{5:-- Command-line completion (^V^N^P) }{19:Back at original} | 5741## grid 5 5742{n: 🍎 f fruit }| 5743{n: 🍌 f fruit }| 5744{n: carrot v vegetable }| 5745{n: plain }| 5746## grid 6 (hidden) 5747{n:An orange vegetable}| 5748]] , 5749float_pos ={ 5750[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 7 , false , 100 , 1 , 1 , 7 } , 5751} , 5752} ) 5753else 5754screen : expect ( [[ 5755DictCmd ^ | 5756{1:~ }{n: 🍎 f fruit }{1: }| 5757{1:~ }{n: 🍌 f fruit }{1: }| 5758{1:~ }{n: carrot v vegetable }{1: }| 5759{1:~ }{n: plain }{1: }| 5760{1:~ }|*6 5761{5:-- Command-line completion (^V^N^P) }{19:Back at original} | 5762]] ) 5763end 5764 5765-- Starting another i_CTRL-X_CTRL-V completion should not leak memory 5766feed ( '<C-U>' ) 5767poke_eventloop () -- Allow pum_check_clear() to remove the info popup. 5768feed ( 'sign un<C-X><C-V>' ) 5769if multigrid then 5770screen : expect ( { 5771grid =[[ 5772## grid 1 5773[2:-------------------------------------------------------]|*11 5774[3:-------------------------------------------------------]| 5775## grid 2 5776sign undefine^ | 5777{1:~ }|*10 5778## grid 3 5779{5:-- Command-line completion (^V^N^P) }{6:match 1 of 2} | 5780## grid 5 5781{12: undefine }| 5782{n: unplace }| 5783]] , 5784float_pos ={ 5785[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 4 , false , 100 , 1 , 1 , 4 } , 5786} , 5787} ) 5788else 5789screen : expect ( [[ 5790sign undefine^ | 5791{1:~ }{12: undefine }{1: }| 5792{1:~ }{n: unplace }{1: }| 5793{1:~ }|*8 5794{5:-- Command-line completion (^V^N^P) }{6:match 1 of 2} | 5795]] ) 5796end 5797end ) 5798 5799-- oldtest: Test_wildmenu_pum_info_mouse_scroll() 5800it ( 'scrolling cmdline pum info popup' , function () 5801screen : try_resize ( 55 , 12 ) 5802exec ( [[ 5803func DictComp(A, L, P) 5804let info = join(map(range(1, 30), '"info line " .. v:val'), "\n") 5805return [ 5806\ {'word': 'apple', 'kind': 'f', 'menu': 'fruit', 'info': info}, 5807\ {'word': 'banana', 'kind': 'f', 'menu': 'fruit', 'info': info}, 5808\ ] 5809endfunc 5810command -nargs=1 -complete=customlist,DictComp DictCmd echo <q-args> 5811set wildmenu wildoptions=pum completeopt=menu,popup mouse=a 5812]] ) 5813 5814feed ( ':DictCmd <Tab>' ) 5815if multigrid then 5816screen : expect ( { 5817grid =[[ 5818## grid 1 5819[2:-------------------------------------------------------]|*11 5820[3:-------------------------------------------------------]| 5821## grid 2 5822| 5823{1:~ }|*10 5824## grid 3 5825:DictCmd apple^ | 5826## grid 4 5827{n:info line 1 }| 5828{n:info line 2 }| 5829{n:info line 3 }| 5830{n:info line 4 }| 5831{n:info line 5 }| 5832{n:info line 6 }| 5833{n:info line 7 }| 5834{n:info line 8 }| 5835{n:info line 9 }| 5836{n:info line 10}| 5837{n:info line 11}| 5838{n:info line 12}| 5839## grid 5 5840{12: apple f fruit }| 5841{n: banana f fruit }| 5842]] , 5843float_pos ={ 5844[ 5 ] ={ - 1 , 'SW' , 1 , 11 , 8 , false , 250 , 3 , 9 , 8 } , 5845[ 4 ] ={ 1001 , 'NW' , 1 , 9 , 24 , true , 50 , 1 , 0 , 24 } , 5846} , 5847} ) 5848else 5849screen : expect ( [[ 5850{n:info line 1 } | 5851{1:~ }{n:info line 2 }{1: }| 5852{1:~ }{n:info line 3 }{1: }| 5853{1:~ }{n:info line 4 }{1: }| 5854{1:~ }{n:info line 5 }{1: }| 5855{1:~ }{n:info line 6 }{1: }| 5856{1:~ }{n:info line 7 }{1: }| 5857{1:~ }{n:info line 8 }{1: }| 5858{1:~ }{n:info line 9 }{1: }| 5859{1:~ }{12: apple f fruit }{n:info line 10}{1: }| 5860{1:~ }{n: banana f fruit info line 11}{1: }| 5861:DictCmd apple^ | 5862]] ) 5863end 5864 5865if send_mouse_grid then 5866api . nvim_input_mouse ( 'wheel' , 'down' , '' , 4 , 0 , 0 ) 5867api . nvim_input_mouse ( 'wheel' , 'down' , '' , 4 , 0 , 0 ) 5868api . nvim_input_mouse ( 'wheel' , 'down' , '' , 4 , 0 , 0 ) 5869else 5870api . nvim_input_mouse ( 'wheel' , 'down' , '' , 0 , 0 , 24 ) 5871api . nvim_input_mouse ( 'wheel' , 'down' , '' , 0 , 0 , 24 ) 5872api . nvim_input_mouse ( 'wheel' , 'down' , '' , 0 , 0 , 24 ) 5873end 5874if multigrid then 5875screen : expect ( { 5876grid =[[ 5877## grid 1 5878[2:-------------------------------------------------------]|*11 5879[3:-------------------------------------------------------]| 5880## grid 2 5881| 5882{1:~ }|*10 5883## grid 3 5884:DictCmd apple^ | 5885## grid 4 5886{n:info line 10}| 5887{n:info line 11}| 5888{n:info line 12}| 5889{n:info line 13}| 5890{n:info line 14}| 5891{n:info line 15}| 5892{n:info line 16}| 5893{n:info line 17}| 5894{n:info line 18}| 5895{n:info line 19}| 5896{n:info line 20}| 5897{n:info line 21}| 5898## grid 5 5899{12: apple f fruit }| 5900{n: banana f fruit }| 5901]] , 5902float_pos ={ 5903[ 5 ] ={ - 1 , 'SW' , 1 , 11 , 8 , false , 250 , 3 , 9 , 8 } , 5904[ 4 ] ={ 1001 , 'NW' , 1 , 9 , 24 , true , 50 , 1 , 0 , 24 } , 5905} , 5906} ) 5907else 5908screen : expect ( [[ 5909{n:info line 10} | 5910{1:~ }{n:info line 11}{1: }| 5911{1:~ }{n:info line 12}{1: }| 5912{1:~ }{n:info line 13}{1: }| 5913{1:~ }{n:info line 14}{1: }| 5914{1:~ }{n:info line 15}{1: }| 5915{1:~ }{n:info line 16}{1: }| 5916{1:~ }{n:info line 17}{1: }| 5917{1:~ }{n:info line 18}{1: }| 5918{1:~ }{12: apple f fruit }{n:info line 19}{1: }| 5919{1:~ }{n: banana f fruit info line 20}{1: }| 5920:DictCmd apple^ | 5921]] ) 5922end 5923 5924if send_mouse_grid then 5925api . nvim_input_mouse ( 'wheel' , 'up' , '' , 4 , 0 , 0 ) 5926api . nvim_input_mouse ( 'wheel' , 'up' , '' , 4 , 0 , 0 ) 5927else 5928api . nvim_input_mouse ( 'wheel' , 'up' , '' , 0 , 0 , 24 ) 5929api . nvim_input_mouse ( 'wheel' , 'up' , '' , 0 , 0 , 24 ) 5930end 5931if multigrid then 5932screen : expect ( { 5933grid =[[ 5934## grid 1 5935[2:-------------------------------------------------------]|*11 5936[3:-------------------------------------------------------]| 5937## grid 2 5938| 5939{1:~ }|*10 5940## grid 3 5941:DictCmd apple^ | 5942## grid 4 5943{n:info line 4 }| 5944{n:info line 5 }| 5945{n:info line 6 }| 5946{n:info line 7 }| 5947{n:info line 8 }| 5948{n:info line 9 }| 5949{n:info line 10}| 5950{n:info line 11}| 5951{n:info line 12}| 5952{n:info line 13}| 5953{n:info line 14}| 5954{n:info line 15}| 5955## grid 5 5956{12: apple f fruit }| 5957{n: banana f fruit }| 5958]] , 5959float_pos ={ 5960[ 5 ] ={ - 1 , 'SW' , 1 , 11 , 8 , false , 250 , 3 , 9 , 8 } , 5961[ 4 ] ={ 1001 , 'NW' , 1 , 9 , 24 , true , 50 , 1 , 0 , 24 } , 5962} , 5963} ) 5964else 5965screen : expect ( [[ 5966{n:info line 4 } | 5967{1:~ }{n:info line 5 }{1: }| 5968{1:~ }{n:info line 6 }{1: }| 5969{1:~ }{n:info line 7 }{1: }| 5970{1:~ }{n:info line 8 }{1: }| 5971{1:~ }{n:info line 9 }{1: }| 5972{1:~ }{n:info line 10}{1: }| 5973{1:~ }{n:info line 11}{1: }| 5974{1:~ }{n:info line 12}{1: }| 5975{1:~ }{12: apple f fruit }{n:info line 13}{1: }| 5976{1:~ }{n: banana f fruit info line 14}{1: }| 5977:DictCmd apple^ | 5978]] ) 5979end 5980 5981feed ( '<Esc>' ) 5982end ) 5983 5984-- oldtest: Test_cmdline_complete_findfunc_dict() 5985it ( "'findfunc' can return extra info for cmdline completion" , function () 5986screen : try_resize ( 55 , 12 ) 5987exec ( [[ 5988set wildmenu wildoptions=pum completeopt=menu,popup 5989func FindComplete(cmdarg, cmdcomplete) 5990return [ 5991\ 'Xplain', 5992\ {'word': 'Xfile1', 'kind': 'F', 'menu': 'file', 'info': '1st file'}, 5993\ {'word': 'Xfile2', 'kind': 'F', 'menu': 'file', 'info': '2nd file'}, 5994\ {'word': 'Xdir1', 'kind': 'D', 'menu': 'dir', 'info': '1st dir'}, 5995\ {'word': 'Xdir2', 'kind': 'D', 'menu': 'dir', 'info': '2nd dir'}, 5996\ ] 5997endfunc 5998set findfunc=FindComplete 5999]] ) 6000 6001feed ( ':find <Tab>' ) 6002if multigrid then 6003screen : expect ( { 6004grid =[[ 6005## grid 1 6006[2:-------------------------------------------------------]|*11 6007[3:-------------------------------------------------------]| 6008## grid 2 6009| 6010{1:~ }|*10 6011## grid 3 6012:find Xplain^ | 6013## grid 4 6014{12: Xplain }| 6015{n: Xfile1 F file }| 6016{n: Xfile2 F file }| 6017{n: Xdir1 D dir }| 6018{n: Xdir2 D dir }| 6019]] , 6020float_pos ={ 6021[ 4 ] ={ - 1 , 'SW' , 1 , 11 , 5 , false , 250 , 2 , 6 , 5 } , 6022} , 6023} ) 6024else 6025screen : expect ( [[ 6026| 6027{1:~ }|*5 6028{1:~ }{12: Xplain }{1: }| 6029{1:~ }{n: Xfile1 F file }{1: }| 6030{1:~ }{n: Xfile2 F file }{1: }| 6031{1:~ }{n: Xdir1 D dir }{1: }| 6032{1:~ }{n: Xdir2 D dir }{1: }| 6033:find Xplain^ | 6034]] ) 6035end 6036 6037feed ( '<PageDown>' ) 6038if multigrid then 6039screen : expect ( { 6040grid =[[ 6041## grid 1 6042[2:-------------------------------------------------------]|*11 6043[3:-------------------------------------------------------]| 6044## grid 2 6045| 6046{1:~ }|*10 6047## grid 3 6048:find Xdir1^ | 6049## grid 4 6050{n: Xplain }| 6051{n: Xfile1 F file }| 6052{n: Xfile2 F file }| 6053{12: Xdir1 D dir }| 6054{n: Xdir2 D dir }| 6055## grid 5 6056{n:1st dir}| 6057]] , 6058float_pos ={ 6059[ 4 ] ={ - 1 , 'SW' , 1 , 11 , 5 , false , 250 , 3 , 6 , 5 } , 6060[ 5 ] ={ 1001 , 'NW' , 1 , 6 , 21 , true , 50 , 1 , 6 , 21 } , 6061} , 6062} ) 6063else 6064screen : expect ( [[ 6065| 6066{1:~ }|*5 6067{1:~ }{n: Xplain 1st dir}{1: }| 6068{1:~ }{n: Xfile1 F file }{1: }| 6069{1:~ }{n: Xfile2 F file }{1: }| 6070{1:~ }{12: Xdir1 D dir }{1: }| 6071{1:~ }{n: Xdir2 D dir }{1: }| 6072:find Xdir1^ | 6073]] ) 6074end 6075end ) 6076 6077it ( "'pumheight'" , function () 6078screen : try_resize ( 32 , 8 ) 6079feed ( 'isome long prefix before the ' ) 6080command ( 'set completeopt+=noinsert,noselect' ) 6081command ( 'set linebreak' ) 6082command ( 'set pumheight=2' ) 6083fn . complete ( 29 , { 'word' , 'choice' , 'text' , 'thing' } ) 6084if multigrid then 6085screen : expect { 6086grid =[[ 6087## grid 1 6088[2:--------------------------------]|*7 6089[3:--------------------------------]| 6090## grid 2 6091some long prefix before the ^ | 6092{1:~ }|*6 6093## grid 3 6094{5:-- INSERT --} | 6095## grid 4 6096{n: word }{c: }| 6097{n: choice }{12: }| 6098]] , 6099float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 14 , false , 100 , 1 , 1 , 14 } } , 6100} 6101else 6102screen : expect ( [[ 6103some long prefix before the ^ | 6104{1:~ }{n: word }{c: }| 6105{1:~ }{n: choice }{12: }| 6106{1:~ }|*4 6107{5:-- INSERT --} | 6108]] ) 6109end 6110end ) 6111 6112it ( "'pumwidth'" , function () 6113screen : try_resize ( 32 , 8 ) 6114feed ( 'isome long prefix before the ' ) 6115command ( 'set completeopt+=noinsert,noselect' ) 6116command ( 'set linebreak' ) 6117command ( 'set pumwidth=8' ) 6118fn . complete ( 29 , { 'word' , 'choice' , 'text' , 'thing' } ) 6119if multigrid then 6120screen : expect { 6121grid =[[ 6122## grid 1 6123[2:--------------------------------]|*7 6124[3:--------------------------------]| 6125## grid 2 6126some long prefix before the ^ | 6127{1:~ }|*6 6128## grid 3 6129{5:-- INSERT --} | 6130## grid 4 6131{n: word }| 6132{n: choice }| 6133{n: text }| 6134{n: thing }| 6135]] , 6136float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 22 , false , 100 , 1 , 1 , 22 } } , 6137} 6138else 6139screen : expect ( [[ 6140some long prefix before the ^ | 6141{1:~ }{n: word }| 6142{1:~ }{n: choice }| 6143{1:~ }{n: text }| 6144{1:~ }{n: thing }| 6145{1:~ }|*2 6146{5:-- INSERT --} | 6147]] ) 6148end 6149end ) 6150 6151-- oldtest: Test_pum_maxwidth() 6152it ( "'pummaxwidth'" , function () 6153screen : try_resize ( 60 , 8 ) 6154api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { 6155'123456789_123456789_123456789_a' , 6156'123456789_123456789_123456789_b' , 6157' 123' , 6158} ) 6159feed ( 'G"zyy' ) 6160feed ( 'A<C-X><C-N>' ) 6161if multigrid then 6162screen : expect ( { 6163grid =[[ 6164## grid 1 6165[2:------------------------------------------------------------]|*7 6166[3:------------------------------------------------------------]| 6167## grid 2 6168123456789_123456789_123456789_a | 6169123456789_123456789_123456789_b | 6170123456789_123456789_123456789_a^ | 6171{1:~ }|*4 6172## grid 3 6173{5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 6174## grid 4 6175{12: 123456789_123456789_123456789_a }| 6176{n: 123456789_123456789_123456789_b }| 6177]] , 6178float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 3 , 11 , false , 100 , 1 , 3 , 11 } } , 6179} ) 6180else 6181screen : expect ( [[ 6182123456789_123456789_123456789_a | 6183123456789_123456789_123456789_b | 6184123456789_123456789_123456789_a^ | 6185{1:~ }{12: 123456789_123456789_123456789_a }{1: }| 6186{1:~ }{n: 123456789_123456789_123456789_b }{1: }| 6187{1:~ }|*2 6188{5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 6189]] ) 6190end 6191feed ( '<Esc>3Gdd"zp' ) 6192 6193command ( 'set pummaxwidth=10' ) 6194feed ( 'GA<C-X><C-N>' ) 6195if multigrid then 6196screen : expect ( { 6197grid =[[ 6198## grid 1 6199[2:------------------------------------------------------------]|*7 6200[3:------------------------------------------------------------]| 6201## grid 2 6202123456789_123456789_123456789_a | 6203123456789_123456789_123456789_b | 6204123456789_123456789_123456789_a^ | 6205{1:~ }|*4 6206## grid 3 6207{5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 6208## grid 4 6209{12: 123456789>}| 6210{n: 123456789>}| 6211]] , 6212float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 3 , 11 , false , 100 , 1 , 3 , 11 } } , 6213} ) 6214else 6215screen : expect ( [[ 6216123456789_123456789_123456789_a | 6217123456789_123456789_123456789_b | 6218123456789_123456789_123456789_a^ | 6219{1:~ }{12: 123456789>}{1: }| 6220{1:~ }{n: 123456789>}{1: }| 6221{1:~ }|*2 6222{5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 6223]] ) 6224end 6225feed ( '<Esc>3Gdd"zp' ) 6226 6227command ( 'set pummaxwidth=20' ) 6228feed ( 'GA<C-X><C-N>' ) 6229if multigrid then 6230screen : expect ( { 6231grid =[[ 6232## grid 1 6233[2:------------------------------------------------------------]|*7 6234[3:------------------------------------------------------------]| 6235## grid 2 6236123456789_123456789_123456789_a | 6237123456789_123456789_123456789_b | 6238123456789_123456789_123456789_a^ | 6239{1:~ }|*4 6240## grid 3 6241{5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 6242## grid 4 6243{12: 123456789_123456789>}| 6244{n: 123456789_123456789>}| 6245]] , 6246float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 3 , 11 , false , 100 , 1 , 3 , 11 } } , 6247} ) 6248else 6249screen : expect ( [[ 6250123456789_123456789_123456789_a | 6251123456789_123456789_123456789_b | 6252123456789_123456789_123456789_a^ | 6253{1:~ }{12: 123456789_123456789>}{1: }| 6254{1:~ }{n: 123456789_123456789>}{1: }| 6255{1:~ }|*2 6256{5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 6257]] ) 6258end 6259feed ( '<Esc>3Gdd"zp' ) 6260 6261command ( 'set pumwidth=20 pummaxwidth=8' ) 6262feed ( 'GA<C-X><C-N>' ) 6263if multigrid then 6264screen : expect ( { 6265grid =[[ 6266## grid 1 6267[2:------------------------------------------------------------]|*7 6268[3:------------------------------------------------------------]| 6269## grid 2 6270123456789_123456789_123456789_a | 6271123456789_123456789_123456789_b | 6272123456789_123456789_123456789_a^ | 6273{1:~ }|*4 6274## grid 3 6275{5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 6276## grid 4 6277{12: 1234567>}| 6278{n: 1234567>}| 6279]] , 6280float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 3 , 11 , false , 100 , 1 , 3 , 11 } } , 6281} ) 6282else 6283screen : expect ( [[ 6284123456789_123456789_123456789_a | 6285123456789_123456789_123456789_b | 6286123456789_123456789_123456789_a^ | 6287{1:~ }{12: 1234567>}{1: }| 6288{1:~ }{n: 1234567>}{1: }| 6289{1:~ }|*2 6290{5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 6291]] ) 6292end 6293feed ( '<Esc>3Gdd"zp' ) 6294 6295screen : try_resize ( 32 , 10 ) 6296feed ( 'GA<C-X><C-N>' ) 6297if multigrid then 6298screen : expect ( { 6299grid =[[ 6300## grid 1 6301[2:--------------------------------]|*9 6302[3:--------------------------------]| 6303## grid 2 6304123456789_123456789_123456789_a | 6305123456789_123456789_123456789_b | 6306123456789_123456789_| 6307123456789_a^ | 6308{1:~ }|*5 6309## grid 3 6310{5:-- }{6:match 1 of 2} | 6311## grid 4 6312{12: 1234567>}| 6313{n: 1234567>}| 6314]] , 6315float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 4 , 11 , false , 100 , 1 , 4 , 11 } } , 6316} ) 6317else 6318screen : expect ( [[ 6319123456789_123456789_123456789_a | 6320123456789_123456789_123456789_b | 6321123456789_123456789_| 6322123456789_a^ | 6323{1:~ }{12: 1234567>}{1: }| 6324{1:~ }{n: 1234567>}{1: }| 6325{1:~ }|*3 6326{5:-- }{6:match 1 of 2} | 6327]] ) 6328end 6329feed ( '<Esc>3Gdd"zp' ) 6330end ) 6331 6332-- oldtest: Test_pum_maxwidth_multibyte() 6333it ( "'pummaxwidth' with multibyte" , function () 6334screen : try_resize ( 60 , 8 ) 6335exec ( [[ 6336hi StrikeFake guifg=DarkRed 6337let g:change = 0 6338func Omni_test(findstart, base) 6339if a:findstart 6340return col(".") 6341endif 6342if g:change == 0 6343return [ 6344\ #{word: "123456789_123456789_123456789_"}, 6345\ #{word: "一二三四五六七八九十"}, 6346\ #{word: "abcdefghij"}, 6347\ #{word: "上下左右"}, 6348\ ] 6349elseif g:change == 1 6350return [ 6351\ #{word: "foo", menu: "fooMenu", kind: "fooKind"}, 6352\ #{word: "bar", menu: "barMenu", kind: "barKind"}, 6353\ #{word: "baz", menu: "bazMenu", kind: "bazKind"}, 6354\ ] 6355elseif g:change == 2 6356return [ 6357\ #{word: "foo", menu: "fooMenu", kind: "fooKind"}, 6358\ #{word: "bar", menu: "fooMenu", kind: "一二三四"}, 6359\ #{word: "一二三四五", kind: "multi"}, 6360\ ] 6361return [#{word: "bar", menu: "fooMenu", kind: "一二三"}] 6362elseif g:change == 3 6363return [#{word: "bar", menu: "fooMenu", kind: "一二三"}] 6364else 6365return [ 6366\ #{word: "一二三四五六七八九十", abbr_hlgroup: "StrikeFake"}, 6367\ #{word: "123456789_123456789_123456789_", abbr_hlgroup: "StrikeFake"}, 6368\ ] 6369endif 6370endfunc 6371set omnifunc=Omni_test 6372set cot+=menuone 6373]] ) 6374 6375feed ( 'S<C-X><C-O>' ) 6376if multigrid then 6377screen : expect ( { 6378grid =[[ 6379## grid 1 6380[2:------------------------------------------------------------]|*7 6381[3:------------------------------------------------------------]| 6382## grid 2 6383123456789_123456789_123456789_^ | 6384{1:~ }|*6 6385## grid 3 6386{5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 6387## grid 4 6388{12:123456789_123456789_123456789_ }| 6389{n:一二三四五六七八九十 }| 6390{n:abcdefghij }| 6391{n:上下左右 }| 6392]] , 6393float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6394} ) 6395else 6396screen : expect ( [[ 6397123456789_123456789_123456789_^ | 6398{12:123456789_123456789_123456789_ }{1: }| 6399{n:一二三四五六七八九十 }{1: }| 6400{n:abcdefghij }{1: }| 6401{n:上下左右 }{1: }| 6402{1:~ }|*2 6403{5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 6404]] ) 6405end 6406feed ( '<Esc>' ) 6407 6408command ( 'set pummaxwidth=10' ) 6409feed ( 'S<C-X><C-O>' ) 6410if multigrid then 6411screen : expect ( { 6412grid =[[ 6413## grid 1 6414[2:------------------------------------------------------------]|*7 6415[3:------------------------------------------------------------]| 6416## grid 2 6417123456789_123456789_123456789_^ | 6418{1:~ }|*6 6419## grid 3 6420{5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 6421## grid 4 6422{12:123456789>}| 6423{n:一二三四 >}| 6424{n:abcdefghij}| 6425{n:上下左右 }| 6426]] , 6427float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6428} ) 6429else 6430screen : expect ( [[ 6431123456789_123456789_123456789_^ | 6432{12:123456789>}{1: }| 6433{n:一二三四 >}{1: }| 6434{n:abcdefghij}{1: }| 6435{n:上下左右 }{1: }| 6436{1:~ }|*2 6437{5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 6438]] ) 6439end 6440feed ( '<Esc>' ) 6441 6442command ( 'set rightleft' ) 6443feed ( 'S<C-X><C-O>' ) 6444if multigrid then 6445screen : expect ( { 6446grid =[[ 6447## grid 1 6448[2:------------------------------------------------------------]|*7 6449[3:------------------------------------------------------------]| 6450## grid 2 6451^ _987654321_987654321_987654321| 6452{1: ~}|*6 6453## grid 3 6454{5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 6455## grid 4 6456{12:<987654321}| 6457{n:< 四三二一}| 6458{n:jihgfedcba}| 6459{n: 右左下上}| 6460]] , 6461float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 50 , false , 100 , 1 , 1 , 50 } } , 6462} ) 6463else 6464screen : expect ( [[ 6465^ _987654321_987654321_987654321| 6466{1: }{12:<987654321}| 6467{1: }{n:< 四三二一}| 6468{1: }{n:jihgfedcba}| 6469{1: }{n: 右左下上}| 6470{1: ~}|*2 6471{5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 6472]] ) 6473end 6474feed ( '<Esc>' ) 6475command ( 'set norightleft' ) 6476 6477command ( 'set pummaxwidth=2' ) 6478feed ( 'S<C-X><C-O>' ) 6479if multigrid then 6480screen : expect ( { 6481grid =[[ 6482## grid 1 6483[2:------------------------------------------------------------]|*7 6484[3:------------------------------------------------------------]| 6485## grid 2 6486123456789_123456789_123456789_^ | 6487{1:~ }|*6 6488## grid 3 6489{5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 6490## grid 4 6491{12:1>}| 6492{n: >}| 6493{n:a>}| 6494{n: >}| 6495]] , 6496float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6497} ) 6498else 6499screen : expect ( [[ 6500123456789_123456789_123456789_^ | 6501{12:1>}{1: }| 6502{n: >}{1: }| 6503{n:a>}{1: }| 6504{n: >}{1: }| 6505{1:~ }|*2 6506{5:-- Omni completion (^O^N^P) }{6:match 1 of 4} | 6507]] ) 6508end 6509feed ( '<Esc>' ) 6510 6511screen : try_resize ( 32 , 20 ) 6512command ( 'set pummaxwidth=14' ) 6513command ( 'let g:change=1' ) 6514feed ( 'S<C-X><C-O>' ) 6515if multigrid then 6516screen : expect ( { 6517grid =[[ 6518## grid 1 6519[2:--------------------------------]|*19 6520[3:--------------------------------]| 6521## grid 2 6522foo^ | 6523{1:~ }|*18 6524## grid 3 6525{5:-- }{6:match 1 of 3} | 6526## grid 4 6527{12:foo fooKind f>}| 6528{n:bar barKind b>}| 6529{n:baz bazKind b>}| 6530]] , 6531float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6532} ) 6533else 6534screen : expect ( [[ 6535foo^ | 6536{12:foo fooKind f>}{1: }| 6537{n:bar barKind b>}{1: }| 6538{n:baz bazKind b>}{1: }| 6539{1:~ }|*15 6540{5:-- }{6:match 1 of 3} | 6541]] ) 6542end 6543feed ( '<Esc>' ) 6544 6545-- Unicode Character U+2026 but one cell 6546command ( 'set fcs+=trunc:…' ) 6547feed ( 'S<C-X><C-O>' ) 6548if multigrid then 6549screen : expect ( { 6550grid =[[ 6551## grid 1 6552[2:--------------------------------]|*19 6553[3:--------------------------------]| 6554## grid 2 6555foo^ | 6556{1:~ }|*18 6557## grid 3 6558{5:-- }{6:match 1 of 3} | 6559## grid 4 6560{12:foo fooKind f…}| 6561{n:bar barKind b…}| 6562{n:baz bazKind b…}| 6563]] , 6564float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6565} ) 6566else 6567screen : expect ( [[ 6568foo^ | 6569{12:foo fooKind f…}{1: }| 6570{n:bar barKind b…}{1: }| 6571{n:baz bazKind b…}{1: }| 6572{1:~ }|*15 6573{5:-- }{6:match 1 of 3} | 6574]] ) 6575end 6576feed ( '<Esc>' ) 6577 6578command ( 'let g:change=2' ) 6579feed ( 'S<C-X><C-O>' ) 6580if multigrid then 6581screen : expect ( { 6582grid =[[ 6583## grid 1 6584[2:--------------------------------]|*19 6585[3:--------------------------------]| 6586## grid 2 6587foo^ | 6588{1:~ }|*18 6589## grid 3 6590{5:-- }{6:match 1 of 3} | 6591## grid 4 6592{12:foo fo…}| 6593{n:bar 一…}| 6594{n:一二三四五 mu…}| 6595]] , 6596float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6597} ) 6598else 6599screen : expect ( [[ 6600foo^ | 6601{12:foo fo…}{1: }| 6602{n:bar 一…}{1: }| 6603{n:一二三四五 mu…}{1: }| 6604{1:~ }|*15 6605{5:-- }{6:match 1 of 3} | 6606]] ) 6607end 6608feed ( '<Esc>' ) 6609 6610command ( 'set fcs&' ) 6611feed ( 'S<C-X><C-O>' ) 6612if multigrid then 6613screen : expect ( { 6614grid =[[ 6615## grid 1 6616[2:--------------------------------]|*19 6617[3:--------------------------------]| 6618## grid 2 6619foo^ | 6620{1:~ }|*18 6621## grid 3 6622{5:-- }{6:match 1 of 3} | 6623## grid 4 6624{12:foo fo>}| 6625{n:bar 一>}| 6626{n:一二三四五 mu>}| 6627]] , 6628float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6629} ) 6630else 6631screen : expect ( [[ 6632foo^ | 6633{12:foo fo>}{1: }| 6634{n:bar 一>}{1: }| 6635{n:一二三四五 mu>}{1: }| 6636{1:~ }|*15 6637{5:-- }{6:match 1 of 3} | 6638]] ) 6639end 6640feed ( '<Esc>' ) 6641 6642command ( 'set fcs=trunc:_' ) 6643command ( 'let g:change=1' ) 6644feed ( 'S<C-X><C-O>' ) 6645if multigrid then 6646screen : expect ( { 6647grid =[[ 6648## grid 1 6649[2:--------------------------------]|*19 6650[3:--------------------------------]| 6651## grid 2 6652foo^ | 6653{1:~ }|*18 6654## grid 3 6655{5:-- }{6:match 1 of 3} | 6656## grid 4 6657{12:foo fooKind f_}| 6658{n:bar barKind b_}| 6659{n:baz bazKind b_}| 6660]] , 6661float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6662} ) 6663else 6664screen : expect ( [[ 6665foo^ | 6666{12:foo fooKind f_}{1: }| 6667{n:bar barKind b_}{1: }| 6668{n:baz bazKind b_}{1: }| 6669{1:~ }|*15 6670{5:-- }{6:match 1 of 3} | 6671]] ) 6672end 6673feed ( '<Esc>' ) 6674command ( 'set fcs&' ) 6675 6676command ( 'set rightleft' ) 6677feed ( 'S<C-X><C-O>' ) 6678if multigrid then 6679screen : expect ( { 6680grid =[[ 6681## grid 1 6682[2:--------------------------------]|*19 6683[3:--------------------------------]| 6684## grid 2 6685^ oof| 6686{1: ~}|*18 6687## grid 3 6688{5:-- }{6:match 1 of 3} | 6689## grid 4 6690{12:<f dniKoof oof}| 6691{n:<b dniKrab rab}| 6692{n:<b dniKzab zab}| 6693]] , 6694float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 18 , false , 100 , 1 , 1 , 18 } } , 6695} ) 6696else 6697screen : expect ( [[ 6698^ oof| 6699{1: }{12:<f dniKoof oof}| 6700{1: }{n:<b dniKrab rab}| 6701{1: }{n:<b dniKzab zab}| 6702{1: ~}|*15 6703{5:-- }{6:match 1 of 3} | 6704]] ) 6705end 6706feed ( '<Esc>' ) 6707 6708command ( 'let g:change=2' ) 6709feed ( 'S<C-X><C-O>' ) 6710if multigrid then 6711screen : expect ( { 6712grid =[[ 6713## grid 1 6714[2:--------------------------------]|*19 6715[3:--------------------------------]| 6716## grid 2 6717^ oof| 6718{1: ~}|*18 6719## grid 3 6720{5:-- }{6:match 1 of 3} | 6721## grid 4 6722{12:<of oof}| 6723{n:<一 rab}| 6724{n:<um 五四三二一}| 6725]] , 6726float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 18 , false , 100 , 1 , 1 , 18 } } , 6727} ) 6728else 6729screen : expect ( [[ 6730^ oof| 6731{1: }{12:<of oof}| 6732{1: }{n:<一 rab}| 6733{1: }{n:<um 五四三二一}| 6734{1: ~}|*15 6735{5:-- }{6:match 1 of 3} | 6736]] ) 6737end 6738feed ( '<Esc>' ) 6739 6740command ( 'set fcs+=truncrl:…' ) 6741feed ( 'S<C-X><C-O>' ) 6742if multigrid then 6743screen : expect ( { 6744grid =[[ 6745## grid 1 6746[2:--------------------------------]|*19 6747[3:--------------------------------]| 6748## grid 2 6749^ oof| 6750{1: ~}|*18 6751## grid 3 6752{5:-- }{6:match 1 of 3} | 6753## grid 4 6754{12:…of oof}| 6755{n:…一 rab}| 6756{n:…um 五四三二一}| 6757]] , 6758float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 18 , false , 100 , 1 , 1 , 18 } } , 6759} ) 6760else 6761screen : expect ( [[ 6762^ oof| 6763{1: }{12:…of oof}| 6764{1: }{n:…一 rab}| 6765{1: }{n:…um 五四三二一}| 6766{1: ~}|*15 6767{5:-- }{6:match 1 of 3} | 6768]] ) 6769end 6770feed ( '<Esc>' ) 6771 6772command ( 'set fcs&' ) 6773command ( 'let g:change=3' ) 6774feed ( 'S<C-X><C-O>' ) 6775if multigrid then 6776screen : expect ( { 6777grid =[[ 6778## grid 1 6779[2:--------------------------------]|*19 6780[3:--------------------------------]| 6781## grid 2 6782^ rab| 6783{1: ~}|*18 6784## grid 3 6785{5:-- The only match} | 6786## grid 4 6787{12:<of 三二一 rab}| 6788]] , 6789float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 18 , false , 100 , 1 , 1 , 18 } } , 6790} ) 6791else 6792screen : expect ( [[ 6793^ rab| 6794{1: }{12:<of 三二一 rab}| 6795{1: ~}|*17 6796{5:-- The only match} | 6797]] ) 6798end 6799feed ( '<Esc>' ) 6800command ( 'set norightleft' ) 6801 6802command ( 'set pummaxwidth=4' ) 6803command ( 'let g:change=2' ) 6804feed ( 'S<C-X><C-O>' ) 6805if multigrid then 6806screen : expect ( { 6807grid =[[ 6808## grid 1 6809[2:--------------------------------]|*19 6810[3:--------------------------------]| 6811## grid 2 6812foo^ | 6813{1:~ }|*18 6814## grid 3 6815{5:-- }{6:match 1 of 3} | 6816## grid 4 6817{12:foo>}| 6818{n:bar>}| 6819{n:一 >}| 6820]] , 6821float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6822} ) 6823else 6824screen : expect ( [[ 6825foo^ | 6826{12:foo>}{1: }| 6827{n:bar>}{1: }| 6828{n:一 >}{1: }| 6829{1:~ }|*15 6830{5:-- }{6:match 1 of 3} | 6831]] ) 6832end 6833feed ( '<Esc>' ) 6834 6835command ( 'set rightleft' ) 6836feed ( 'S<C-X><C-O>' ) 6837if multigrid then 6838screen : expect ( { 6839grid =[[ 6840## grid 1 6841[2:--------------------------------]|*19 6842[3:--------------------------------]| 6843## grid 2 6844^ oof| 6845{1: ~}|*18 6846## grid 3 6847{5:-- }{6:match 1 of 3} | 6848## grid 4 6849{12:<oof}| 6850{n:<rab}| 6851{n:< 一}| 6852]] , 6853float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 28 , false , 100 , 1 , 1 , 28 } } , 6854} ) 6855else 6856screen : expect ( [[ 6857^ oof| 6858{1: }{12:<oof}| 6859{1: }{n:<rab}| 6860{1: }{n:< 一}| 6861{1: ~}|*15 6862{5:-- }{6:match 1 of 3} | 6863]] ) 6864end 6865feed ( '<Esc>' ) 6866command ( 'set norightleft' ) 6867 6868command ( 'set pummaxwidth=16' ) 6869feed ( 'S<C-X><C-O>' ) 6870if multigrid then 6871screen : expect ( { 6872grid =[[ 6873## grid 1 6874[2:--------------------------------]|*19 6875[3:--------------------------------]| 6876## grid 2 6877foo^ | 6878{1:~ }|*18 6879## grid 3 6880{5:-- }{6:match 1 of 3} | 6881## grid 4 6882{12:foo fooK>}| 6883{n:bar 一二>}| 6884{n:一二三四五 multi}| 6885]] , 6886float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6887} ) 6888else 6889screen : expect ( [[ 6890foo^ | 6891{12:foo fooK>}{1: }| 6892{n:bar 一二>}{1: }| 6893{n:一二三四五 multi}{1: }| 6894{1:~ }|*15 6895{5:-- }{6:match 1 of 3} | 6896]] ) 6897end 6898feed ( '<Esc>' ) 6899 6900command ( 'set rightleft' ) 6901feed ( 'S<C-X><C-O>' ) 6902if multigrid then 6903screen : expect ( { 6904grid =[[ 6905## grid 1 6906[2:--------------------------------]|*19 6907[3:--------------------------------]| 6908## grid 2 6909^ oof| 6910{1: ~}|*18 6911## grid 3 6912{5:-- }{6:match 1 of 3} | 6913## grid 4 6914{12:<Koof oof}| 6915{n:<二一 rab}| 6916{n:itlum 五四三二一}| 6917]] , 6918float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 16 , false , 100 , 1 , 1 , 16 } } , 6919} ) 6920else 6921screen : expect ( [[ 6922^ oof| 6923{1: }{12:<Koof oof}| 6924{1: }{n:<二一 rab}| 6925{1: }{n:itlum 五四三二一}| 6926{1: ~}|*15 6927{5:-- }{6:match 1 of 3} | 6928]] ) 6929end 6930feed ( '<Esc>' ) 6931command ( 'set norightleft' ) 6932 6933command ( 'let g:change=4' ) 6934feed ( 'S<C-X><C-O>' ) 6935if multigrid then 6936screen : expect ( { 6937grid =[[ 6938## grid 1 6939[2:--------------------------------]|*19 6940[3:--------------------------------]| 6941## grid 2 6942一二三四五六七八九十^ | 6943{1:~ }|*18 6944## grid 3 6945{5:-- }{6:match 1 of 2} | 6946## grid 4 6947{ds:一二三四五六七 }{12:>}| 6948{dn:123456789_12345}{n:>}| 6949]] , 6950float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 6951} ) 6952else 6953screen : expect ( [[ 6954一二三四五六七八九十^ | 6955{ds:一二三四五六七 }{12:>}{1: }| 6956{dn:123456789_12345}{n:>}{1: }| 6957{1:~ }|*16 6958{5:-- }{6:match 1 of 2} | 6959]] ) 6960end 6961feed ( '<Esc>' ) 6962end ) 6963 6964-- oldtest: Test_pum_position_when_wrap() 6965it ( 'with cursor on a wrapped line' , function () 6966exec ( [[ 6967func Omni_test(findstart, base) 6968if a:findstart 6969return col(".") 6970endif 6971return ['foo', 'bar', 'foobar'] 6972endfunc 6973set omnifunc=Omni_test 6974set wrap 6975set cot+=noinsert 6976]] ) 6977screen : try_resize ( 25 , 15 ) 6978 6979insert (( 'abcde ' ): rep ( 20 )) 6980 6981feed ( '5|' ) 6982feed ( 'a<C-X><C-O>' ) 6983if multigrid then 6984screen : expect ( { 6985float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 3 , 4 , false , 100 , 1 , 3 , 4 } } , 6986} ) 6987else 6988screen : expect ( [[ 6989abcde^ abcde abcde abcde a| 6990bcde abcde abcde abcde ab| 6991cde abcde abcde abcde abc| 6992de a{12: foo } abcd| 6993e ab{n: bar } | 6994{1:~ }{n: foobar }{1: }| 6995{1:~ }|*8 6996{5:-- }{6:match 1 of 3} | 6997]] ) 6998end 6999feed ( '<Esc>' ) 7000 7001feed ( '30|' ) 7002feed ( 'a<C-X><C-O>' ) 7003if multigrid then 7004screen : expect ( { 7005float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 4 , 4 , false , 100 , 1 , 4 , 4 } } , 7006} ) 7007else 7008screen : expect ( [[ 7009abcde abcde abcde abcde a| 7010bcde ^abcde abcde abcde ab| 7011cde abcde abcde abcde abc| 7012de abcde abcde abcde abcd| 7013e ab{12: foo } | 7014{1:~ }{n: bar }{1: }| 7015{1:~ }{n: foobar }{1: }| 7016{1:~ }|*7 7017{5:-- }{6:match 1 of 3} | 7018]] ) 7019end 7020feed ( '<Esc>' ) 7021 7022feed ( '55|' ) 7023feed ( 'a<C-X><C-O>' ) 7024if multigrid then 7025screen : expect ( { 7026float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 5 , 4 , false , 100 , 1 , 5 , 4 } } , 7027} ) 7028else 7029screen : expect ( [[ 7030abcde abcde abcde abcde a| 7031bcde abcde abcde abcde ab| 7032cde a^bcde abcde abcde abc| 7033de abcde abcde abcde abcd| 7034e abcde abcde abcde | 7035{1:~ }{12: foo }{1: }| 7036{1:~ }{n: bar }{1: }| 7037{1:~ }{n: foobar }{1: }| 7038{1:~ }|*6 7039{5:-- }{6:match 1 of 3} | 7040]] ) 7041end 7042feed ( '<Esc>' ) 7043 7044feed ( '85|' ) 7045feed ( 'a<C-X><C-O>' ) 7046if multigrid then 7047screen : expect ( { 7048float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 5 , 9 , false , 100 , 1 , 5 , 9 } } , 7049} ) 7050else 7051screen : expect ( [[ 7052abcde abcde abcde abcde a| 7053bcde abcde abcde abcde ab| 7054cde abcde abcde abcde abc| 7055de abcde a^bcde abcde abcd| 7056e abcde abcde abcde | 7057{1:~ }{12: foo }| 7058{1:~ }{n: bar }| 7059{1:~ }{n: foobar }| 7060{1:~ }|*6 7061{5:-- }{6:match 1 of 3} | 7062]] ) 7063end 7064feed ( '<C-E><Esc>' ) 7065 7066feed ( '108|' ) 7067feed ( 'a<C-X><C-O>' ) 7068if multigrid then 7069screen : expect ( { 7070float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 5 , 7 , false , 100 , 1 , 5 , 7 } } , 7071} ) 7072else 7073screen : expect ( [[ 7074abcde abcde abcde abcde a| 7075bcde abcde abcde abcde ab| 7076cde abcde abcde abcde abc| 7077de abcde abcde abcde abcd| 7078e abcde ^abcde abcde | 7079{1:~ }{12: foo }{1: }| 7080{1:~ }{n: bar }{1: }| 7081{1:~ }{n: foobar }{1: }| 7082{1:~ }|*6 7083{5:-- }{6:match 1 of 3} | 7084]] ) 7085end 7086feed ( '<C-E><Esc>' ) 7087end ) 7088 7089it ( 'does not crash when displayed in last column with rightleft #12032' , function () 7090local col =30 7091local items ={ 'word' , 'choice' , 'text' , 'thing' } 7092local max_len =0 7093for _ , v in ipairs ( items ) do 7094max_len =max_len < # v and # v or max_len 7095end 7096screen : try_resize ( col , 8 ) 7097command ( 'set rightleft' ) 7098command ( 'call setline(1, repeat(" ", &columns - ' .. max_len .. '))' ) 7099feed ( '$i' ) 7100fn . complete ( col - max_len , items ) 7101feed ( '<c-y>' ) 7102assert_alive () 7103end ) 7104 7105it ( 'truncates double-width character correctly without scrollbar' , function () 7106screen : try_resize ( 32 , 8 ) 7107command ( 'set completeopt+=menuone,noselect' ) 7108feed ( 'i' .. string . rep ( ' ' , 13 )) 7109 7110fn . complete ( 14 , { '一二三四五六七八九十' } ) 7111if multigrid then 7112screen : expect ( { 7113grid =[[ 7114## grid 1 7115[2:--------------------------------]|*7 7116[3:--------------------------------]| 7117## grid 2 7118^ | 7119{1:~ }|*6 7120## grid 3 7121{5:-- INSERT --} | 7122## grid 4 7123{n: 一二三四五六七八九>}| 7124]] , 7125float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 12 , false , 100 , 1 , 1 , 12 } } , 7126} ) 7127else 7128screen : expect ( [[ 7129^ | 7130{1:~ }{n: 一二三四五六七八九>}| 7131{1:~ }|*5 7132{5:-- INSERT --} | 7133]] ) 7134end 7135feed ( '<C-E>' ) 7136 7137fn . complete ( 14 , { { word ='一二三' , kind ='四五六' , menu ='七八九十' } } ) 7138if multigrid then 7139screen : expect ( { 7140grid =[[ 7141## grid 1 7142[2:--------------------------------]|*7 7143[3:--------------------------------]| 7144## grid 2 7145^ | 7146{1:~ }|*6 7147## grid 3 7148{5:-- INSERT --} | 7149## grid 4 7150{n: 一二三 四五六 七八>}| 7151]] , 7152float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 12 , false , 100 , 1 , 1 , 12 } } , 7153} ) 7154else 7155screen : expect ( [[ 7156^ | 7157{1:~ }{n: 一二三 四五六 七八>}| 7158{1:~ }|*5 7159{5:-- INSERT --} | 7160]] ) 7161end 7162feed ( '<C-E>' ) 7163 7164command ( 'set rightleft' ) 7165fn . complete ( 14 , { '一二三四五六七八九十' } ) 7166if multigrid then 7167screen : expect ( { 7168grid =[[ 7169## grid 1 7170[2:--------------------------------]|*7 7171[3:--------------------------------]| 7172## grid 2 7173^ | 7174{1: ~}|*6 7175## grid 3 7176{5:-- INSERT --} | 7177## grid 4 7178{n:<九八七六五四三二一 }| 7179]] , 7180float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 7181} ) 7182else 7183screen : expect ( [[ 7184^ | 7185{n:<九八七六五四三二一 }{1: ~}| 7186{1: ~}|*5 7187{5:-- INSERT --} | 7188]] ) 7189end 7190feed ( '<C-E>' ) 7191 7192fn . complete ( 14 , { { word ='一二三' , kind ='四五六' , menu ='七八九十' } } ) 7193if multigrid then 7194screen : expect ( { 7195grid =[[ 7196## grid 1 7197[2:--------------------------------]|*7 7198[3:--------------------------------]| 7199## grid 2 7200^ | 7201{1: ~}|*6 7202## grid 3 7203{5:-- INSERT --} | 7204## grid 4 7205{n:<八七 六五四 三二一 }| 7206]] , 7207float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 7208} ) 7209else 7210screen : expect ( [[ 7211^ | 7212{n:<八七 六五四 三二一 }{1: ~}| 7213{1: ~}|*5 7214{5:-- INSERT --} | 7215]] ) 7216end 7217feed ( '<C-E>' ) 7218end ) 7219 7220it ( 'truncates double-width character correctly with scrollbar' , function () 7221screen : try_resize ( 32 , 8 ) 7222command ( 'set completeopt+=noselect' ) 7223command ( 'set pumheight=4' ) 7224feed ( 'i' .. string . rep ( ' ' , 12 )) 7225local items1 ={} 7226local items2 ={} 7227for _ =1 , 8 do 7228table . insert ( items1 , { word ='一二三四五六七八九十' , equal =1 , dup =1 } ) 7229end 7230for _ =1 , 2 do 7231table . insert ( 7232items2 , 7233{ word ='abcdef' , kind ='ghijkl' , menu ='mnopqrst' , equal =1 , dup =1 } 7234) 7235end 7236for _ =3 , 8 do 7237table . insert ( 7238items2 , 7239{ word ='一二三' , kind ='四五六' , menu ='七八九十' , equal =1 , dup =1 } 7240) 7241end 7242 7243fn . complete ( 13 , items1 ) 7244if multigrid then 7245screen : expect ( { 7246grid =[[ 7247## grid 1 7248[2:--------------------------------]|*7 7249[3:--------------------------------]| 7250## grid 2 7251^ | 7252{1:~ }|*6 7253## grid 3 7254{5:-- INSERT --} | 7255## grid 4 7256{n: 一二三四五六七八九>}{c: }|*2 7257{n: 一二三四五六七八九>}{12: }|*2 7258]] , 7259float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 11 , false , 100 , 1 , 1 , 11 } } , 7260} ) 7261else 7262screen : expect ( [[ 7263^ | 7264{1:~ }{n: 一二三四五六七八九>}{c: }|*2 7265{1:~ }{n: 一二三四五六七八九>}{12: }|*2 7266{1:~ }|*2 7267{5:-- INSERT --} | 7268]] ) 7269end 7270feed ( '<C-E>' ) 7271 7272fn . complete ( 13 , items2 ) 7273if multigrid then 7274screen : expect ( { 7275grid =[[ 7276## grid 1 7277[2:--------------------------------]|*7 7278[3:--------------------------------]| 7279## grid 2 7280^ | 7281{1:~ }|*6 7282## grid 3 7283{5:-- INSERT --} | 7284## grid 4 7285{n: abcdef ghijkl mnop>}{c: }|*2 7286{n: 一二三 四五六 七八>}{12: }|*2 7287]] , 7288float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 11 , false , 100 , 1 , 1 , 11 } } , 7289} ) 7290else 7291screen : expect ( [[ 7292^ | 7293{1:~ }{n: abcdef ghijkl mnop>}{c: }|*2 7294{1:~ }{n: 一二三 四五六 七八>}{12: }|*2 7295{1:~ }|*2 7296{5:-- INSERT --} | 7297]] ) 7298end 7299feed ( '<C-E>' ) 7300 7301command ( 'set rightleft' ) 7302fn . complete ( 13 , items1 ) 7303if multigrid then 7304screen : expect ( { 7305grid =[[ 7306## grid 1 7307[2:--------------------------------]|*7 7308[3:--------------------------------]| 7309## grid 2 7310^ | 7311{1: ~}|*6 7312## grid 3 7313{5:-- INSERT --} | 7314## grid 4 7315{c: }{n:<九八七六五四三二一 }|*2 7316{12: }{n:<九八七六五四三二一 }|*2 7317]] , 7318float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 7319} ) 7320else 7321screen : expect ( [[ 7322^ | 7323{c: }{n:<九八七六五四三二一 }{1: ~}|*2 7324{12: }{n:<九八七六五四三二一 }{1: ~}|*2 7325{1: ~}|*2 7326{5:-- INSERT --} | 7327]] ) 7328end 7329feed ( '<C-E>' ) 7330 7331fn . complete ( 13 , items2 ) 7332if multigrid then 7333screen : expect ( { 7334grid =[[ 7335## grid 1 7336[2:--------------------------------]|*7 7337[3:--------------------------------]| 7338## grid 2 7339^ | 7340{1: ~}|*6 7341## grid 3 7342{5:-- INSERT --} | 7343## grid 4 7344{c: }{n:<ponm lkjihg fedcba }|*2 7345{12: }{n:<八七 六五四 三二一 }|*2 7346]] , 7347float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } } , 7348} ) 7349else 7350screen : expect ( [[ 7351^ | 7352{c: }{n:<ponm lkjihg fedcba }{1: ~}|*2 7353{12: }{n:<八七 六五四 三二一 }{1: ~}|*2 7354{1: ~}|*2 7355{5:-- INSERT --} | 7356]] ) 7357end 7358feed ( '<C-E>' ) 7359end ) 7360 7361it ( 'supports mousemodel=popup' , function () 7362screen : try_resize ( 32 , 6 ) 7363exec ( [[ 7364call setline(1, 'popup menu test') 7365set mouse=a mousemodel=popup 7366 7367" Delete the default MenuPopup event handler. 7368autocmd! nvim.popupmenu 7369aunmenu PopUp 7370menu PopUp.foo :let g:menustr = 'foo'<CR> 7371menu PopUp.bar :let g:menustr = 'bar'<CR> 7372menu PopUp.baz :let g:menustr = 'baz'<CR> 7373]] ) 7374 7375--- @param state string|test.functional.ui.screen.Expect 7376--- @param str string 7377--- @param repl string 7378--- @return string|test.functional.ui.screen.Expect 7379local function screen_replace ( state , str , repl ) 7380if type ( state ) == 'string' then 7381local new_state =state : gsub ( vim . pesc ( str ), vim . pesc ( repl )) 7382return new_state 7383end 7384local new_state =vim . deepcopy ( state ) 7385local grid =assert ( new_state . grid ) 7386grid =grid : gsub ( vim . pesc ( str ), vim . pesc ( repl )) 7387new_state . grid =grid 7388return new_state 7389end 7390 7391local no_sel_screen ---@type string|test.function.ui.screen.Expect 7392if send_mouse_grid then 7393api . nvim_input_mouse ( 'right' , 'press' , '' , 2 , 0 , 4 ) 7394else 7395feed ( '<RightMouse><4,0>' ) 7396end 7397if multigrid then 7398no_sel_screen ={ 7399grid =[[ 7400## grid 1 7401[2:--------------------------------]|*5 7402[3:--------------------------------]| 7403## grid 2 7404^popup menu test | 7405{1:~ }|*4 7406## grid 3 7407| 7408## grid 4 7409{n: foo }| 7410{n: bar }| 7411{n: baz }| 7412]] , 7413float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 3 , false , 250 , 2 , 1 , 3 } } , 7414} 7415else 7416no_sel_screen =[[ 7417^popup menu test | 7418{1:~ }{n: foo }{1: }| 7419{1:~ }{n: bar }{1: }| 7420{1:~ }{n: baz }{1: }| 7421{1:~ }| 7422| 7423]] 7424end 7425screen : expect ( no_sel_screen ) 7426feed ( '<Down>' ) 7427screen : expect ( screen_replace ( no_sel_screen , '{n: foo }' , '{12: foo }' )) 7428feed ( '<Down>' ) 7429screen : expect ( screen_replace ( no_sel_screen , '{n: bar }' , '{12: bar }' )) 7430feed ( '<CR>' ) 7431local no_menu_screen ---@type string 7432if multigrid then 7433no_menu_screen =[[ 7434## grid 1 7435[2:--------------------------------]|*5 7436[3:--------------------------------]| 7437## grid 2 7438^popup menu test | 7439{1:~ }|*4 7440## grid 3 7441:let g:menustr = 'bar' | 7442]] 7443else 7444no_menu_screen =[[ 7445^popup menu test | 7446{1:~ }|*4 7447:let g:menustr = 'bar' | 7448]] 7449end 7450screen : expect ( no_menu_screen ) 7451eq ( 'bar' , api . nvim_get_var ( 'menustr' )) 7452 7453if send_mouse_grid then 7454api . nvim_input_mouse ( 'right' , 'press' , '' , 2 , 2 , 20 ) 7455else 7456feed ( '<RightMouse><20,2>' ) 7457end 7458if multigrid then 7459screen : expect ( { 7460grid =[[ 7461## grid 1 7462[2:--------------------------------]|*5 7463[3:--------------------------------]| 7464## grid 2 7465^popup menu test | 7466{1:~ }|*4 7467## grid 3 7468:let g:menustr = 'bar' | 7469## grid 4 7470{n: foo }| 7471{n: bar }| 7472{n: baz }| 7473]] , 7474float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 3 , 19 , false , 250 , 2 , 3 , 19 } } , 7475} ) 7476else 7477screen : expect ( [[ 7478^popup menu test | 7479{1:~ }|*2 7480{1:~ }{n: foo }{1: }| 7481{1:~ }{n: bar }{1: }| 7482:let g:menustr = 'b{n: baz } | 7483]] ) 7484end 7485if send_mouse_grid then 7486api . nvim_input_mouse ( 'right' , 'press' , '' , 2 , 0 , 18 ) 7487else 7488feed ( '<RightMouse><18,0>' ) 7489end 7490if multigrid then 7491screen : expect ( { 7492grid =[[ 7493## grid 1 7494[2:--------------------------------]|*5 7495[3:--------------------------------]| 7496## grid 2 7497^popup menu test | 7498{1:~ }|*4 7499## grid 3 7500:let g:menustr = 'bar' | 7501## grid 4 7502{n: foo }| 7503{n: bar }| 7504{n: baz }| 7505]] , 7506float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 17 , false , 250 , 2 , 1 , 17 } } , 7507} ) 7508else 7509screen : expect ( [[ 7510^popup menu test | 7511{1:~ }{n: foo }{1: }| 7512{1:~ }{n: bar }{1: }| 7513{1:~ }{n: baz }{1: }| 7514{1:~ }| 7515:let g:menustr = 'bar' | 7516]] ) 7517end 7518if send_mouse_grid then 7519api . nvim_input_mouse ( 'right' , 'press' , '' , 4 , 1 , 3 ) 7520else 7521feed ( '<RightMouse><20,2>' ) 7522end 7523if multigrid then 7524screen : expect ( { 7525grid =[[ 7526## grid 1 7527[2:--------------------------------]|*5 7528[3:--------------------------------]| 7529## grid 2 7530^popup menu test | 7531{1:~ }|*4 7532## grid 3 7533:let g:menustr = 'bar' | 7534## grid 4 7535{n: foo }| 7536{n: bar }| 7537{n: baz }| 7538]] , 7539float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 3 , 19 , false , 250 , 2 , 3 , 19 } } , 7540} ) 7541else 7542screen : expect ( [[ 7543^popup menu test | 7544{1:~ }|*2 7545{1:~ }{n: foo }{1: }| 7546{1:~ }{n: bar }{1: }| 7547:let g:menustr = 'b{n: baz } | 7548]] ) 7549end 7550if send_mouse_grid then 7551api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 2 , 2 ) 7552else 7553feed ( '<LeftMouse><21,5>' ) 7554end 7555no_menu_screen =no_menu_screen : gsub ( [['bar']] , [['baz']] ) 7556screen : expect ( no_menu_screen ) 7557eq ( 'baz' , api . nvim_get_var ( 'menustr' )) 7558 7559if send_mouse_grid then 7560api . nvim_input_mouse ( 'right' , 'press' , '' , 2 , 0 , 4 ) 7561else 7562feed ( '<RightMouse><4,0>' ) 7563end 7564if multigrid then 7565no_sel_screen ={ 7566grid =[[ 7567## grid 1 7568[2:--------------------------------]|*5 7569[3:--------------------------------]| 7570## grid 2 7571^popup menu test | 7572{1:~ }|*4 7573## grid 3 7574:let g:menustr = 'baz' | 7575## grid 4 7576{n: foo }| 7577{n: bar }| 7578{n: baz }| 7579]] , 7580float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 3 , false , 250 , 2 , 1 , 3 } } , 7581} 7582else 7583no_sel_screen =[[ 7584^popup menu test | 7585{1:~ }{n: foo }{1: }| 7586{1:~ }{n: bar }{1: }| 7587{1:~ }{n: baz }{1: }| 7588{1:~ }| 7589:let g:menustr = 'baz' | 7590]] 7591end 7592screen : expect ( no_sel_screen ) 7593if send_mouse_grid then 7594api . nvim_input_mouse ( 'right' , 'drag' , '' , 2 , 3 , 6 ) 7595else 7596feed ( '<RightDrag><6,3>' ) 7597end 7598screen : expect ( screen_replace ( no_sel_screen , '{n: baz }' , '{12: baz }' )) 7599if send_mouse_grid then 7600api . nvim_input_mouse ( 'right' , 'release' , '' , 2 , 1 , 6 ) 7601else 7602feed ( '<RightRelease><6,1>' ) 7603end 7604no_menu_screen =no_menu_screen : gsub ( [['baz']] , [['foo']] ) 7605screen : expect ( no_menu_screen ) 7606eq ( 'foo' , api . nvim_get_var ( 'menustr' )) 7607no_sel_screen =screen_replace ( no_sel_screen , [['baz']] , [['foo']] ) 7608 7609eq ( false , screen . options . mousemoveevent ) 7610 7611if send_mouse_grid then 7612api . nvim_input_mouse ( 'right' , 'press' , '' , 2 , 0 , 4 ) 7613else 7614feed ( '<RightMouse><4,0>' ) 7615end 7616screen : expect ( no_sel_screen ) 7617eq ( true , screen . options . mousemoveevent ) 7618if send_mouse_grid then 7619api . nvim_input_mouse ( 'wheel' , 'up' , '' , 2 , 0 , 4 ) 7620else 7621feed ( '<ScrollWheelUp><4,0>' ) 7622end 7623screen : expect ( screen_replace ( no_sel_screen , '{n: foo }' , '{12: foo }' )) 7624eq ( true , screen . options . mousemoveevent ) 7625if send_mouse_grid then 7626api . nvim_input_mouse ( 'move' , '' , '' , 4 , 2 , 3 ) 7627else 7628feed ( '<MouseMove><6,3>' ) 7629end 7630screen : expect ( screen_replace ( no_sel_screen , '{n: baz }' , '{12: baz }' )) 7631eq ( true , screen . options . mousemoveevent ) 7632if send_mouse_grid then 7633api . nvim_input_mouse ( 'wheel' , 'down' , '' , 4 , 2 , 3 ) 7634else 7635feed ( '<ScrollWheelDown><6,3>' ) 7636end 7637screen : expect ( screen_replace ( no_sel_screen , '{n: bar }' , '{12: bar }' )) 7638eq ( true , screen . options . mousemoveevent ) 7639if send_mouse_grid then 7640api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 1 , 3 ) 7641else 7642feed ( '<LeftMouse><6,2>' ) 7643end 7644no_menu_screen =no_menu_screen : gsub ( [['foo']] , [['bar']] ) 7645screen : expect ( no_menu_screen ) 7646eq ( false , screen . options . mousemoveevent ) 7647eq ( 'bar' , api . nvim_get_var ( 'menustr' )) 7648 7649command ( 'set laststatus=0 | botright split' ) 7650if send_mouse_grid then 7651api . nvim_input_mouse ( 'right' , 'press' , '' , 5 , 1 , 20 ) 7652else 7653feed ( '<RightMouse><20,4>' ) 7654end 7655if multigrid then 7656screen : expect ( { 7657grid =[[ 7658## grid 1 7659[2:--------------------------------]|*2 7660{2:[No Name] [+] }| 7661[5:--------------------------------]|*2 7662[3:--------------------------------]| 7663## grid 2 7664popup menu test | 7665{1:~ }| 7666## grid 3 7667:let g:menustr = 'bar' | 7668## grid 4 7669{n: foo }| 7670{n: bar }| 7671{n: baz }| 7672## grid 5 7673^popup menu test | 7674{1:~ }| 7675]] , 7676float_pos ={ [ 4 ] ={ - 1 , 'SW' , 5 , 1 , 19 , false , 250 , 2 , 1 , 19 } } , 7677} ) 7678else 7679screen : expect ( [[ 7680popup menu test | 7681{1:~ }{n: foo }{1: }| 7682{2:[No Name] [+] }{n: bar }{2: }| 7683^popup menu test {n: baz } | 7684{1:~ }| 7685:let g:menustr = 'bar' | 7686]] ) 7687end 7688if send_mouse_grid then 7689api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 2 , 2 ) 7690else 7691feed ( '<LeftMouse><21,3>' ) 7692end 7693if multigrid then 7694screen : expect ( [[ 7695## grid 1 7696[2:--------------------------------]|*2 7697{2:[No Name] [+] }| 7698[5:--------------------------------]|*2 7699[3:--------------------------------]| 7700## grid 2 7701popup menu test | 7702{1:~ }| 7703## grid 3 7704:let g:menustr = 'baz' | 7705## grid 5 7706^popup menu test | 7707{1:~ }| 7708]] ) 7709else 7710screen : expect ( [[ 7711popup menu test | 7712{1:~ }| 7713{2:[No Name] [+] }| 7714^popup menu test | 7715{1:~ }| 7716:let g:menustr = 'baz' | 7717]] ) 7718end 7719eq ( 'baz' , api . nvim_get_var ( 'menustr' )) 7720 7721command ( 'set winwidth=1 | rightbelow vsplit' ) 7722if send_mouse_grid then 7723api . nvim_input_mouse ( 'right' , 'press' , '' , 6 , 1 , 14 ) 7724else 7725feed ( '<RightMouse><30,4>' ) 7726end 7727if multigrid then 7728screen : expect ( { 7729grid =[[ 7730## grid 1 7731[2:--------------------------------]|*2 7732{2:[No Name] [+] }| 7733[5:---------------]│[6:----------------]|*2 7734[3:--------------------------------]| 7735## grid 2 7736popup menu test | 7737{1:~ }| 7738## grid 3 7739:let g:menustr = 'baz' | 7740## grid 4 7741{n: foo}| 7742{n: bar}| 7743{n: baz}| 7744## grid 5 7745popup menu test| 7746{1:~ }| 7747## grid 6 7748^popup menu test | 7749{1:~ }| 7750]] , 7751float_pos ={ [ 4 ] ={ - 1 , 'SW' , 6 , 1 , 12 , false , 250 , 2 , 1 , 28 } } , 7752} ) 7753else 7754screen : expect ( [[ 7755popup menu test | 7756{1:~ }{n: foo}| 7757{2:[No Name] [+] }{n: bar}| 7758popup menu test│^popup menu t{n: baz}| 7759{1:~ }│{1:~ }| 7760:let g:menustr = 'baz' | 7761]] ) 7762end 7763if send_mouse_grid then 7764api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 0 , 2 ) 7765else 7766feed ( '<LeftMouse><31,1>' ) 7767end 7768if multigrid then 7769screen : expect ( [[ 7770## grid 1 7771[2:--------------------------------]|*2 7772{2:[No Name] [+] }| 7773[5:---------------]│[6:----------------]|*2 7774[3:--------------------------------]| 7775## grid 2 7776popup menu test | 7777{1:~ }| 7778## grid 3 7779:let g:menustr = 'foo' | 7780## grid 5 7781popup menu test| 7782{1:~ }| 7783## grid 6 7784^popup menu test | 7785{1:~ }| 7786]] ) 7787else 7788screen : expect ( [[ 7789popup menu test | 7790{1:~ }| 7791{2:[No Name] [+] }| 7792popup menu test│^popup menu test | 7793{1:~ }│{1:~ }| 7794:let g:menustr = 'foo' | 7795]] ) 7796end 7797eq ( 'foo' , api . nvim_get_var ( 'menustr' )) 7798 7799command ( 'setlocal winbar=WINBAR' ) 7800if send_mouse_grid then 7801api . nvim_input_mouse ( 'right' , 'press' , '' , 6 , 1 , 14 ) 7802else 7803feed ( '<RightMouse><30,4>' ) 7804end 7805if multigrid then 7806no_sel_screen ={ 7807grid =[[ 7808## grid 1 7809[2:--------------------------------]|*2 7810{2:[No Name] [+] }| 7811[5:---------------]│[6:----------------]|*2 7812[3:--------------------------------]| 7813## grid 2 7814popup menu test | 7815{1:~ }| 7816## grid 3 7817:let g:menustr = 'foo' | 7818## grid 4 7819{n: foo}| 7820{n: bar}| 7821{n: baz}| 7822## grid 5 7823popup menu test| 7824{1:~ }| 7825## grid 6 7826{5:WINBAR }| 7827^popup menu test | 7828]] , 7829float_pos ={ [ 4 ] ={ - 1 , 'SW' , 6 , 1 , 12 , false , 250 , 2 , 1 , 28 } } , 7830} 7831else 7832no_sel_screen =[[ 7833popup menu test | 7834{1:~ }{n: foo}| 7835{2:[No Name] [+] }{n: bar}| 7836popup menu test│{5:WINBAR }{n: baz}| 7837{1:~ }│^popup menu test | 7838:let g:menustr = 'foo' | 7839]] 7840end 7841screen : expect ( no_sel_screen ) 7842if send_mouse_grid then 7843api . nvim_input_mouse ( 'right' , 'drag' , '' , 6 , 0 , 15 ) 7844else 7845feed ( '<RightDrag><31,3>' ) 7846end 7847screen : expect ( screen_replace ( no_sel_screen , '{n: baz}' , '{12: baz}' )) 7848if send_mouse_grid then 7849api . nvim_input_mouse ( 'right' , 'release' , '' , 6 , 1 , 15 ) 7850else 7851feed ( '<RightRelease><31,4>' ) 7852end 7853screen : expect ( no_sel_screen ) 7854if send_mouse_grid then 7855api . nvim_input_mouse ( 'left' , 'press' , '' , 4 , 1 , 2 ) 7856else 7857feed ( '<LeftMouse><31,2>' ) 7858end 7859if multigrid then 7860screen : expect ( [[ 7861## grid 1 7862[2:--------------------------------]|*2 7863{2:[No Name] [+] }| 7864[5:---------------]│[6:----------------]|*2 7865[3:--------------------------------]| 7866## grid 2 7867popup menu test | 7868{1:~ }| 7869## grid 3 7870:let g:menustr = 'bar' | 7871## grid 5 7872popup menu test| 7873{1:~ }| 7874## grid 6 7875{5:WINBAR }| 7876^popup menu test | 7877]] ) 7878else 7879screen : expect ( [[ 7880popup menu test | 7881{1:~ }| 7882{2:[No Name] [+] }| 7883popup menu test│{5:WINBAR }| 7884{1:~ }│^popup menu test | 7885:let g:menustr = 'bar' | 7886]] ) 7887end 7888eq ( 'bar' , api . nvim_get_var ( 'menustr' )) 7889 7890command ( [[let g:menustr = '']] ) 7891screen : try_resize ( 32 , 9 ) 7892command ( 'wincmd t | 4vsplit | wincmd l | topleft 1split' ) 7893if multigrid then 7894no_menu_screen =[[ 7895## grid 1 7896[8:--------------------------------]| 7897{3:[No Name] [+] }| 7898[7:----]│[2:---------------------------]|*2 7899{2:<+] [No Name] [+] }| 7900[5:---------------]│[6:----------------]|*3 7901[3:--------------------------------]| 7902## grid 2 7903popup menu test | 7904{1:~ }| 7905## grid 3 7906| 7907## grid 5 7908popup menu test| 7909{1:~ }|*2 7910## grid 6 7911{5:WINBAR }| 7912popup menu test | 7913{1:~ }| 7914## grid 7 7915popu| 7916p me| 7917## grid 8 7918^popup menu test | 7919]] 7920else 7921no_menu_screen =[[ 7922^popup menu test | 7923{3:[No Name] [+] }| 7924popu│popup menu test | 7925p me│{1:~ }| 7926{2:<+] [No Name] [+] }| 7927popup menu test│{5:WINBAR }| 7928{1:~ }│popup menu test | 7929{1:~ }│{1:~ }| 7930| 7931]] 7932end 7933screen : expect ( no_menu_screen ) 7934 7935if multigrid then 7936no_sel_screen ={ 7937grid =[[ 7938## grid 1 7939[8:--------------------------------]| 7940{3:[No Name] [+] }| 7941[7:----]│[2:---------------------------]|*2 7942{2:<+] [No Name] [+] }| 7943[5:---------------]│[6:----------------]|*3 7944[3:--------------------------------]| 7945## grid 2 7946popup menu test | 7947{1:~ }| 7948## grid 3 7949| 7950## grid 4 7951{n: foo }| 7952{n: bar }| 7953{n: baz }| 7954## grid 5 7955popup menu test| 7956{1:~ }|*2 7957## grid 6 7958{5:WINBAR }| 7959popup menu test | 7960{1:~ }| 7961## grid 7 7962popu| 7963p me| 7964## grid 8 7965^popup menu test | 7966]] , 7967float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 14 , false , 250 , 2 , 3 , 19 } } , 7968} 7969else 7970no_sel_screen =[[ 7971^popup menu test | 7972{3:[No Name] [+] }| 7973popu│popup menu test | 7974p me│{1:~ }{n: foo }{1: }| 7975{2:<+] [No Name] [+] }{n: bar }{2: }| 7976popup menu test│{5:WIN}{n: baz }{5: }| 7977{1:~ }│popup menu test | 7978{1:~ }│{1:~ }| 7979| 7980]] 7981end 7982 7983local pos ={ 7984{ 0 , 2 , 20 } , 7985{ 0 , 3 , 19 } , 7986{ 0 , 3 , 18 } , 7987{ 0 , 4 , 23 } , 7988{ 0 , 4 , 24 } , 7989{ 0 , 5 , 19 } , 7990{ 0 , 5 , 18 } , 7991} 7992if send_mouse_grid then 7993for i =1 , 7 do 7994local _ , row , col =unpack ( pos [ i ]) 7995pos [ i ] ={ 2 , row - 2 , col - 5 } 7996end 7997end 7998 7999api . nvim_input_mouse ( 'right' , 'press' , '' , unpack ( pos [ 1 ])) 8000screen : expect ( no_sel_screen ) 8001api . nvim_input_mouse ( 'right' , 'drag' , '' , unpack ( pos [ 2 ])) 8002screen : expect ( screen_replace ( no_sel_screen , '{n: foo }' , '{12: foo }' )) 8003api . nvim_input_mouse ( 'right' , 'drag' , '' , unpack ( pos [ 3 ])) 8004screen : expect ( no_sel_screen ) 8005api . nvim_input_mouse ( 'right' , 'drag' , '' , unpack ( pos [ 4 ])) 8006screen : expect ( screen_replace ( no_sel_screen , '{n: bar }' , '{12: bar }' )) 8007api . nvim_input_mouse ( 'right' , 'drag' , '' , unpack ( pos [ 5 ])) 8008screen : expect ( no_sel_screen ) 8009api . nvim_input_mouse ( 'right' , 'drag' , '' , unpack ( pos [ 6 ])) 8010screen : expect ( screen_replace ( no_sel_screen , '{n: baz }' , '{12: baz }' )) 8011api . nvim_input_mouse ( 'right' , 'release' , '' , unpack ( pos [ 7 ])) 8012screen : expect ( no_sel_screen ) 8013api . nvim_input_mouse ( 'left' , 'press' , '' , unpack ( pos [ 7 ])) 8014screen : expect ( no_menu_screen ) 8015eq ( '' , api . nvim_get_var ( 'menustr' )) 8016 8017if send_mouse_grid then 8018for i =2 , 6 , 2 do 8019local _ , row , col =unpack ( pos [ i ]) 8020pos [ i ] ={ 4 , row - 1 , col - 14 } 8021end 8022end 8023 8024api . nvim_input_mouse ( 'right' , 'press' , '' , unpack ( pos [ 1 ])) 8025screen : expect ( no_sel_screen ) 8026api . nvim_input_mouse ( 'move' , '' , '' , unpack ( pos [ 2 ])) 8027screen : expect ( screen_replace ( no_sel_screen , '{n: foo }' , '{12: foo }' )) 8028api . nvim_input_mouse ( 'move' , '' , '' , unpack ( pos [ 3 ])) 8029screen : expect ( no_sel_screen ) 8030api . nvim_input_mouse ( 'move' , '' , '' , unpack ( pos [ 4 ])) 8031screen : expect ( screen_replace ( no_sel_screen , '{n: bar }' , '{12: bar }' )) 8032api . nvim_input_mouse ( 'move' , '' , '' , unpack ( pos [ 5 ])) 8033screen : expect ( no_sel_screen ) 8034api . nvim_input_mouse ( 'move' , '' , '' , unpack ( pos [ 6 ])) 8035screen : expect ( screen_replace ( no_sel_screen , '{n: baz }' , '{12: baz }' )) 8036api . nvim_input_mouse ( 'left' , 'press' , '' , unpack ( pos [ 7 ])) 8037screen : expect ( no_menu_screen ) 8038eq ( '' , api . nvim_get_var ( 'menustr' )) 8039 8040command ( 'set rightleft | wincmd p | set rightleft | wincmd p' ) 8041if multigrid then 8042no_menu_screen =[[ 8043## grid 1 8044[8:--------------------------------]| 8045{3:[No Name] [+] }| 8046[7:----]│[2:---------------------------]|*2 8047{2:<+] [No Name] [+] }| 8048[5:---------------]│[6:----------------]|*3 8049[3:--------------------------------]| 8050## grid 2 8051tset unem pupop| 8052{1: ~}| 8053## grid 3 8054| 8055## grid 5 8056popup menu test| 8057{1:~ }|*2 8058## grid 6 8059{5:WINBAR }| 8060popup menu test | 8061{1:~ }| 8062## grid 7 8063popu| 8064p me| 8065## grid 8 8066tset unem pupo^p| 8067]] 8068else 8069no_menu_screen =[[ 8070tset unem pupo^p| 8071{3:[No Name] [+] }| 8072popu│ tset unem pupop| 8073p me│{1: ~}| 8074{2:<+] [No Name] [+] }| 8075popup menu test│{5:WINBAR }| 8076{1:~ }│popup menu test | 8077{1:~ }│{1:~ }| 8078| 8079]] 8080end 8081screen : expect ( no_menu_screen ) 8082 8083if multigrid then 8084no_sel_screen ={ 8085grid =[[ 8086## grid 1 8087[8:--------------------------------]| 8088{3:[No Name] [+] }| 8089[7:----]│[2:---------------------------]|*2 8090{2:<+] [No Name] [+] }| 8091[5:---------------]│[6:----------------]|*3 8092[3:--------------------------------]| 8093## grid 2 8094tset unem pupop| 8095{1: ~}| 8096## grid 3 8097| 8098## grid 4 8099{n: oof }| 8100{n: rab }| 8101{n: zab }| 8102## grid 5 8103popup menu test| 8104{1:~ }|*2 8105## grid 6 8106{5:WINBAR }| 8107popup menu test | 8108{1:~ }| 8109## grid 7 8110popu| 8111p me| 8112## grid 8 8113tset unem pupo^p| 8114]] , 8115float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 12 , false , 250 , 2 , 3 , 17 } } , 8116} 8117else 8118no_sel_screen =[[ 8119tset unem pupo^p| 8120{3:[No Name] [+] }| 8121popu│ tset unem pupop| 8122p me│{1: }{n: oof }{1: ~}| 8123{2:<+] [No Name] [+}{n: rab }{2: }| 8124popup menu test│{5:W}{n: zab }{5: }| 8125{1:~ }│popup menu test | 8126{1:~ }│{1:~ }| 8127| 8128]] 8129end 8130 8131pos ={ 8132{ 0 , 2 , 20 } , 8133{ 0 , 3 , 21 } , 8134{ 0 , 3 , 22 } , 8135{ 0 , 4 , 17 } , 8136{ 0 , 4 , 16 } , 8137{ 0 , 5 , 21 } , 8138{ 0 , 5 , 22 } , 8139} 8140if send_mouse_grid then 8141for i =1 , 7 do 8142local _ , row , col =unpack ( pos [ i ]) 8143pos [ i ] ={ 2 , row - 2 , col - 5 } 8144end 8145end 8146 8147api . nvim_input_mouse ( 'right' , 'press' , '' , unpack ( pos [ 1 ])) 8148screen : expect ( no_sel_screen ) 8149api . nvim_input_mouse ( 'move' , '' , '' , unpack ( pos [ 2 ])) 8150screen : expect ( screen_replace ( no_sel_screen , '{n: oof }' , '{12: oof }' )) 8151api . nvim_input_mouse ( 'move' , '' , '' , unpack ( pos [ 3 ])) 8152screen : expect ( no_sel_screen ) 8153api . nvim_input_mouse ( 'move' , '' , '' , unpack ( pos [ 4 ])) 8154screen : expect ( screen_replace ( no_sel_screen , '{n: rab }' , '{12: rab }' )) 8155api . nvim_input_mouse ( 'move' , '' , '' , unpack ( pos [ 5 ])) 8156screen : expect ( no_sel_screen ) 8157api . nvim_input_mouse ( 'move' , '' , '' , unpack ( pos [ 6 ])) 8158screen : expect ( screen_replace ( no_sel_screen , '{n: zab }' , '{12: zab }' )) 8159api . nvim_input_mouse ( 'left' , 'press' , '' , unpack ( pos [ 7 ])) 8160screen : expect ( no_menu_screen ) 8161eq ( '' , api . nvim_get_var ( 'menustr' )) 8162 8163if send_mouse_grid then 8164for i =2 , 6 , 2 do 8165local _ , row , col =unpack ( pos [ i ]) 8166pos [ i ] ={ 4 , row - 1 , col - 12 } 8167end 8168end 8169 8170api . nvim_input_mouse ( 'right' , 'press' , '' , unpack ( pos [ 1 ])) 8171screen : expect ( no_sel_screen ) 8172api . nvim_input_mouse ( 'right' , 'drag' , '' , unpack ( pos [ 2 ])) 8173screen : expect ( screen_replace ( no_sel_screen , '{n: oof }' , '{12: oof }' )) 8174api . nvim_input_mouse ( 'right' , 'drag' , '' , unpack ( pos [ 3 ])) 8175screen : expect ( no_sel_screen ) 8176api . nvim_input_mouse ( 'right' , 'drag' , '' , unpack ( pos [ 4 ])) 8177screen : expect ( screen_replace ( no_sel_screen , '{n: rab }' , '{12: rab }' )) 8178api . nvim_input_mouse ( 'right' , 'drag' , '' , unpack ( pos [ 5 ])) 8179screen : expect ( no_sel_screen ) 8180api . nvim_input_mouse ( 'right' , 'drag' , '' , unpack ( pos [ 6 ])) 8181screen : expect ( screen_replace ( no_sel_screen , '{n: zab }' , '{12: zab }' )) 8182api . nvim_input_mouse ( 'right' , 'release' , '' , unpack ( pos [ 7 ])) 8183screen : expect ( no_sel_screen ) 8184api . nvim_input_mouse ( 'left' , 'press' , '' , unpack ( pos [ 7 ])) 8185eq ( '' , api . nvim_get_var ( 'menustr' )) 8186 8187command ( 'set norightleft' ) 8188end ) 8189 8190if not multigrid then 8191-- oldtest: Test_popup_command_dump() 8192it ( ':popup command' , function () 8193exec ( [[ 8194" Delete the default MenuPopup event handler. 8195autocmd! nvim.popupmenu 8196 8197func ChangeMenu() 8198aunmenu PopUp.&Paste 8199nnoremenu 1.40 PopUp.&Paste :echomsg "pasted"<CR> 8200echomsg 'changed' 8201return "\<Ignore>" 8202endfunc 8203 8204let lines =<< trim END 8205one two three four five 8206and one two Xthree four five 8207one more two three four five 8208END 8209call setline(1, lines) 8210 8211aunmenu * 8212source $VIMRUNTIME/menu.vim 8213]] ) 8214feed ( '/X<CR>:popup PopUp<CR>' ) 8215screen : expect ( [[ 8216one two three four five | 8217and one two {10:^X}three four five | 8218one more tw{n: Undo } | 8219{1:~ }{n: }{1: }| 8220{1:~ }{n: Paste }{1: }| 8221{1:~ }{n: }{1: }| 8222{1:~ }{n: Select Word }{1: }| 8223{1:~ }{n: Select Sentence }{1: }| 8224{1:~ }{n: Select Paragraph }{1: }| 8225{1:~ }{n: Select Line }{1: }| 8226{1:~ }{n: Select Block }{1: }| 8227{1:~ }{n: Select All }{1: }| 8228{1:~ }|*7 8229:popup PopUp | 8230]] ) 8231 8232-- go to the Paste entry in the menu 8233feed ( 'jj' ) 8234screen : expect ( [[ 8235one two three four five | 8236and one two {10:^X}three four five | 8237one more tw{n: Undo } | 8238{1:~ }{n: }{1: }| 8239{1:~ }{12: Paste }{1: }| 8240{1:~ }{n: }{1: }| 8241{1:~ }{n: Select Word }{1: }| 8242{1:~ }{n: Select Sentence }{1: }| 8243{1:~ }{n: Select Paragraph }{1: }| 8244{1:~ }{n: Select Line }{1: }| 8245{1:~ }{n: Select Block }{1: }| 8246{1:~ }{n: Select All }{1: }| 8247{1:~ }|*7 8248:popup PopUp | 8249]] ) 8250 8251-- Select a word 8252feed ( 'j' ) 8253screen : expect ( [[ 8254one two three four five | 8255and one two {10:^X}three four five | 8256one more tw{n: Undo } | 8257{1:~ }{n: }{1: }| 8258{1:~ }{n: Paste }{1: }| 8259{1:~ }{n: }{1: }| 8260{1:~ }{12: Select Word }{1: }| 8261{1:~ }{n: Select Sentence }{1: }| 8262{1:~ }{n: Select Paragraph }{1: }| 8263{1:~ }{n: Select Line }{1: }| 8264{1:~ }{n: Select Block }{1: }| 8265{1:~ }{n: Select All }{1: }| 8266{1:~ }|*7 8267:popup PopUp | 8268]] ) 8269 8270feed ( '<Esc>' ) 8271 8272command ( 'set rightleft' ) 8273feed ( '/X<CR>:popup PopUp<CR>' ) 8274screen : expect ( [[ 8275evif ruof eerht owt eno| 8276evif ruof eerht{10:^X} owt eno dna| 8277{n: odnU }wt erom eno| 8278{1: }{n: }{1: ~}| 8279{1: }{n: etsaP }{1: ~}| 8280{1: }{n: }{1: ~}| 8281{1: }{n: droW tceleS }{1: ~}| 8282{1: }{n: ecnetneS tceleS }{1: ~}| 8283{1: }{n: hpargaraP tceleS }{1: ~}| 8284{1: }{n: eniL tceleS }{1: ~}| 8285{1: }{n: kcolB tceleS }{1: ~}| 8286{1: }{n: llA tceleS }{1: ~}| 8287{1: ~}|*7 8288:popup PopUp | 8289]] ) 8290feed ( '<Esc>' ) 8291command ( 'set norightleft' ) 8292 8293-- Set an <expr> mapping to change a menu entry while it's displayed. 8294-- The text should not change but the command does. 8295-- Also verify that "changed" shows up, which means the mapping triggered. 8296command ( 'nnoremap <expr> <F2> ChangeMenu()' ) 8297feed ( '/X<CR>:popup PopUp<CR><F2>' ) 8298screen : expect ( [[ 8299one two three four five | 8300and one two {10:^X}three four five | 8301one more tw{n: Undo } | 8302{1:~ }{n: }{1: }| 8303{1:~ }{n: Paste }{1: }| 8304{1:~ }{n: }{1: }| 8305{1:~ }{n: Select Word }{1: }| 8306{1:~ }{n: Select Sentence }{1: }| 8307{1:~ }{n: Select Paragraph }{1: }| 8308{1:~ }{n: Select Line }{1: }| 8309{1:~ }{n: Select Block }{1: }| 8310{1:~ }{n: Select All }{1: }| 8311{1:~ }|*7 8312changed | 8313]] ) 8314 8315-- Select the Paste entry, executes the changed menu item. 8316feed ( 'jj<CR>' ) 8317screen : expect ( [[ 8318one two three four five | 8319and one two {10:^X}three four five | 8320one more two three four five | 8321{1:~ }|*16 8322pasted | 8323]] ) 8324 8325-- Add a window toolbar to the window and check the :popup menu position. 8326command ( 'setlocal winbar=TEST' ) 8327feed ( '/X<CR>:popup PopUp<CR>' ) 8328screen : expect ( [[ 8329{5:TEST }| 8330one two three four five | 8331and one two {10:^X}three four five | 8332one more tw{n: Undo } | 8333{1:~ }{n: }{1: }| 8334{1:~ }{n: Paste }{1: }| 8335{1:~ }{n: }{1: }| 8336{1:~ }{n: Select Word }{1: }| 8337{1:~ }{n: Select Sentence }{1: }| 8338{1:~ }{n: Select Paragraph }{1: }| 8339{1:~ }{n: Select Line }{1: }| 8340{1:~ }{n: Select Block }{1: }| 8341{1:~ }{n: Select All }{1: }| 8342{1:~ }|*6 8343:popup PopUp | 8344]] ) 8345 8346feed ( '<Esc>' ) 8347end ) 8348end 8349 8350-- oldtest: Test_mouse_popup_position() 8351it ( 'position of right-click menu when clicking near edge' , function () 8352screen : try_resize ( 50 , 20 ) 8353exec ( [[ 8354set mousemodel=popup_setpos 8355" Delete the default MenuPopup event handler. 8356autocmd! nvim.popupmenu 8357aunmenu * 8358source $VIMRUNTIME/menu.vim 8359call setline(1, join(range(20))) 8360]] ) 8361 8362if send_mouse_grid then 8363api . nvim_input_mouse ( 'right' , 'press' , '' , 2 , 0 , 45 - 1 ) 8364else 8365api . nvim_input_mouse ( 'right' , 'press' , '' , 0 , 0 , 45 - 1 ) 8366end 8367if multigrid then 8368screen : expect ( { 8369grid =[[ 8370## grid 1 8371[2:--------------------------------------------------]|*19 8372[3:--------------------------------------------------]| 8373## grid 2 83740 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ^18 19 | 8375{1:~ }|*18 8376## grid 3 8377| 8378## grid 4 8379{n: Undo }| 8380{n: }| 8381{n: Paste }| 8382{n: }| 8383{n: Select Word }| 8384{n: Select Sentence }| 8385{n: Select Paragraph}| 8386{n: Select Line }| 8387{n: Select Block }| 8388{n: Select All }| 8389]] , 8390float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 33 , false , 250 , 2 , 1 , 33 } } , 8391} ) 8392else 8393screen : expect ( [[ 83940 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ^18 19 | 8395{1:~ }{n: Undo }| 8396{1:~ }{n: }| 8397{1:~ }{n: Paste }| 8398{1:~ }{n: }| 8399{1:~ }{n: Select Word }| 8400{1:~ }{n: Select Sentence }| 8401{1:~ }{n: Select Paragraph}| 8402{1:~ }{n: Select Line }| 8403{1:~ }{n: Select Block }| 8404{1:~ }{n: Select All }| 8405{1:~ }|*8 8406| 8407]] ) 8408end 8409feed ( '<Esc>' ) 8410 8411command ( 'set rightleft' ) 8412if send_mouse_grid then 8413api . nvim_input_mouse ( 'right' , 'press' , '' , 2 , 0 , 50 - 45 ) 8414else 8415api . nvim_input_mouse ( 'right' , 'press' , '' , 0 , 0 , 50 - 45 ) 8416end 8417if multigrid then 8418screen : expect ( { 8419grid =[[ 8420## grid 1 8421[2:--------------------------------------------------]|*19 8422[3:--------------------------------------------------]| 8423## grid 2 842491 8^1 71 61 51 41 31 21 11 01 9 8 7 6 5 4 3 2 1 0| 8425{1: ~}|*18 8426## grid 3 8427| 8428## grid 4 8429{n: odnU }| 8430{n: }| 8431{n: etsaP }| 8432{n: }| 8433{n: droW tceleS }| 8434{n: ecnetneS tceleS }| 8435{n:hpargaraP tceleS }| 8436{n: eniL tceleS }| 8437{n: kcolB tceleS }| 8438{n: llA tceleS }| 8439]] , 8440float_pos ={ [ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 250 , 2 , 1 , 0 } } , 8441} ) 8442else 8443screen : expect ( [[ 844491 8^1 71 61 51 41 31 21 11 01 9 8 7 6 5 4 3 2 1 0| 8445{n: odnU }{1: ~}| 8446{n: }{1: ~}| 8447{n: etsaP }{1: ~}| 8448{n: }{1: ~}| 8449{n: droW tceleS }{1: ~}| 8450{n: ecnetneS tceleS }{1: ~}| 8451{n:hpargaraP tceleS }{1: ~}| 8452{n: eniL tceleS }{1: ~}| 8453{n: kcolB tceleS }{1: ~}| 8454{n: llA tceleS }{1: ~}| 8455{1: ~}|*8 8456| 8457]] ) 8458end 8459feed ( '<Esc>' ) 8460command ( 'set norightleft' ) 8461end ) 8462 8463if not multigrid then 8464describe ( '"kind" and "menu"' , function () 8465before_each ( function () 8466screen : try_resize ( 30 , 8 ) 8467exec ( [[ 8468func CompleteFunc( findstart, base ) 8469if a:findstart 8470return 0 8471endif 8472return { 8473\ 'words': [ 8474\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', }, 8475\ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', }, 8476\ { 'word': 'aword3', 'menu': 'extra text 3', 'kind': 'W', }, 8477\]} 8478endfunc 8479set completeopt=menu 8480set completefunc=CompleteFunc 8481]] ) 8482end ) 8483 8484-- oldtest: Test_pum_highlights_default() 8485it ( 'default highlight groups' , function () 8486feed ( 'iaw<C-X><C-u>' ) 8487screen : expect ( [[ 8488aword1^ | 8489{12:aword1 W extra text 1 }{1: }| 8490{n:aword2 W extra text 2 }{1: }| 8491{n:aword3 W extra text 3 }{1: }| 8492{1:~ }|*3 8493{5:-- }{6:match 1 of 3} | 8494]] ) 8495end ) 8496 8497-- oldtest: Test_pum_highlights_custom() 8498it ( 'custom highlight groups' , function () 8499exec ( [[ 8500hi PmenuKind guifg=Red guibg=Plum1 8501hi PmenuKindSel guifg=Red guibg=Grey 8502hi PmenuExtra guifg=White guibg=Plum1 8503hi PmenuExtraSel guifg=Black guibg=Grey 8504]] ) 8505feed ( 'iaw<C-X><C-u>' ) 8506screen : expect ( [[ 8507aword1^ | 8508{12:aword1 }{ks:W }{xs:extra text 1 }{1: }| 8509{n:aword2 }{kn:W }{xn:extra text 2 }{1: }| 8510{n:aword3 }{kn:W }{xn:extra text 3 }{1: }| 8511{1:~ }|*3 8512{5:-- }{6:match 1 of 3} | 8513]] ) 8514end ) 8515end ) 8516 8517-- oldtest: Test_pum_highlights_match() 8518it ( 'can highlight matched text' , function () 8519exec ( [[ 8520func Omni_test(findstart, base) 8521if a:findstart 8522return col(".") 8523endif 8524return { 8525\ 'words': [ 8526\ { 'word': 'foo', 'kind': 'fookind' }, 8527\ { 'word': 'foofoo', 'kind': 'fookind' }, 8528\ { 'word': 'foobar', 'kind': 'fookind' }, 8529\ { 'word': 'fooBaz', 'kind': 'fookind' }, 8530\ { 'word': 'foobala', 'kind': 'fookind' }, 8531\ { 'word': '你好' }, 8532\ { 'word': '你好吗' }, 8533\ { 'word': '你不好吗' }, 8534\ { 'word': '你可好吗' }, 8535\]} 8536endfunc 8537 8538func Comp() 8539let col = col('.') 8540if getline('.') == 'f' 8541let col -= 1 8542endif 8543call complete(col, [ 8544\ #{word: "foo", icase: 1}, 8545\ #{word: "Foobar", icase: 1}, 8546\ #{word: "fooBaz", icase: 1}, 8547\]) 8548return '' 8549endfunc 8550 8551set omnifunc=Omni_test 8552set completeopt=menu,noinsert,fuzzy 8553hi PmenuMatchSel guifg=Blue guibg=Grey 8554hi PmenuMatch guifg=Blue guibg=Plum1 8555]] ) 8556feed ( 'i<C-X><C-O>' ) 8557local pum_start =[[ 8558^ | 8559{12:foo fookind }{1: }| 8560{n:foofoo fookind }{1: }| 8561{n:foobar fookind }{1: }| 8562{n:fooBaz fookind }{1: }| 8563{n:foobala fookind }{1: }| 8564{n:你好 }{1: }| 8565{n:你好吗 }{1: }| 8566{n:你不好吗 }{1: }| 8567{n:你可好吗 }{1: }| 8568{1:~ }|*9 8569{5:-- }{6:match 1 of 9} | 8570]] 8571screen : expect ( pum_start ) 8572feed ( 'fo' ) 8573screen : expect ( [[ 8574fo^ | 8575{ms:fo}{12:o fookind }{1: }| 8576{mn:fo}{n:ofoo fookind }{1: }| 8577{mn:fo}{n:obar fookind }{1: }| 8578{mn:fo}{n:oBaz fookind }{1: }| 8579{mn:fo}{n:obala fookind }{1: }| 8580{1:~ }|*13 8581{5:-- }{6:match 1 of 9} | 8582]] ) 8583feed ( '<Esc>S<C-X><C-O>' ) 8584screen : expect ( pum_start ) 8585feed ( '你' ) 8586screen : expect ( [[ 8587你^ | 8588{ms:你}{12:好 }{1: }| 8589{mn:你}{n:好吗 }{1: }| 8590{mn:你}{n:不好吗 }{1: }| 8591{mn:你}{n:可好吗 }{1: }| 8592{1:~ }|*14 8593{5:-- }{6:match 1 of 9} | 8594]] ) 8595feed ( '吗' ) 8596screen : expect ( [[ 8597你吗^ | 8598{ms:你}{12:好}{ms:吗}{12: }{1: }| 8599{mn:你}{n:不好}{mn:吗}{n: }{1: }| 8600{mn:你}{n:可好}{mn:吗}{n: }{1: }| 8601{1:~ }|*15 8602{5:-- }{6:match 1 of 9} | 8603]] ) 8604feed ( '<C-E><Esc>' ) 8605 8606command ( 'set rightleft' ) 8607feed ( 'S<C-X><C-O>' ) 8608local pum_start_rl =[[ 8609^ | 8610{1: }{12: dnikoof oof}| 8611{1: }{n: dnikoof oofoof}| 8612{1: }{n: dnikoof raboof}| 8613{1: }{n: dnikoof zaBoof}| 8614{1: }{n: dnikoof alaboof}| 8615{1: }{n: 好你}| 8616{1: }{n: 吗好你}| 8617{1: }{n: 吗好不你}| 8618{1: }{n: 吗好可你}| 8619{1: ~}|*9 8620{5:-- }{6:match 1 of 9} | 8621]] 8622screen : expect ( pum_start_rl ) 8623feed ( 'fo' ) 8624screen : expect ( [[ 8625^ of| 8626{1: }{12: dnikoof o}{ms:of}| 8627{1: }{n: dnikoof oofo}{mn:of}| 8628{1: }{n: dnikoof rabo}{mn:of}| 8629{1: }{n: dnikoof zaBo}{mn:of}| 8630{1: }{n: dnikoof alabo}{mn:of}| 8631{1: ~}|*13 8632{5:-- }{6:match 1 of 9} | 8633]] ) 8634feed ( '<Esc>S<C-X><C-O>' ) 8635screen : expect ( pum_start_rl ) 8636feed ( '你' ) 8637screen : expect ( [[ 8638^ 你| 8639{1: }{12: 好}{ms:你}| 8640{1: }{n: 吗好}{mn:你}| 8641{1: }{n: 吗好不}{mn:你}| 8642{1: }{n: 吗好可}{mn:你}| 8643{1: ~}|*14 8644{5:-- }{6:match 1 of 9} | 8645]] ) 8646feed ( '吗' ) 8647screen : expect ( [[ 8648^ 吗你| 8649{1: }{12: }{ms:吗}{12:好}{ms:你}| 8650{1: }{n: }{mn:吗}{n:好不}{mn:你}| 8651{1: }{n: }{mn:吗}{n:好可}{mn:你}| 8652{1: ~}|*15 8653{5:-- }{6:match 1 of 9} | 8654]] ) 8655feed ( '<C-E><Esc>' ) 8656command ( 'set norightleft' ) 8657 8658command ( 'set completeopt-=fuzzy' ) 8659feed ( 'S<C-X><C-O>' ) 8660screen : expect ( pum_start ) 8661feed ( 'fo' ) 8662screen : expect ( [[ 8663fo^ | 8664{ms:fo}{12:o fookind }{1: }| 8665{mn:fo}{n:ofoo fookind }{1: }| 8666{mn:fo}{n:obar fookind }{1: }| 8667{mn:fo}{n:oBaz fookind }{1: }| 8668{mn:fo}{n:obala fookind }{1: }| 8669{1:~ }|*13 8670{5:-- }{6:match 1 of 9} | 8671]] ) 8672feed ( '<C-E><Esc>' ) 8673 8674command ( 'set rightleft' ) 8675feed ( 'S<C-X><C-O>' ) 8676screen : expect ( pum_start_rl ) 8677feed ( 'fo' ) 8678screen : expect ( [[ 8679^ of| 8680{1: }{12: dnikoof o}{ms:of}| 8681{1: }{n: dnikoof oofo}{mn:of}| 8682{1: }{n: dnikoof rabo}{mn:of}| 8683{1: }{n: dnikoof zaBo}{mn:of}| 8684{1: }{n: dnikoof alabo}{mn:of}| 8685{1: ~}|*13 8686{5:-- }{6:match 1 of 9} | 8687]] ) 8688feed ( '<C-E><Esc>' ) 8689command ( 'set norightleft' ) 8690 8691feed ( 'S<C-R>=Comp()<CR>f' ) 8692screen : expect ( [[ 8693f^ | 8694{ms:f}{12:oo }{1: }| 8695{mn:F}{n:oobar }{1: }| 8696{mn:f}{n:ooBaz }{1: }| 8697{1:~ }|*15 8698{5:-- INSERT --} | 8699]] ) 8700feed ( 'o<BS><C-R>=Comp()<CR>' ) 8701screen : expect_unchanged ( true ) 8702feed ( '<C-E><Esc>' ) 8703 8704command ( 'hi PmenuMatchSel guibg=NONE' ) 8705command ( 'hi PmenuMatch guibg=NONE' ) 8706command ( 'set cot=menu,noinsert,fuzzy' ) 8707feed ( 'S<C-X><C-O>' ) 8708screen : expect ( pum_start ) 8709feed ( 'fb' ) 8710screen : expect ( [[ 8711fb^ | 8712{ms:f}{12:oo}{ms:B}{12:az fookind }{1: }| 8713{mn:f}{n:oo}{mn:b}{n:ar fookind }{1: }| 8714{mn:f}{n:oo}{mn:b}{n:ala fookind }{1: }| 8715{1:~ }|*15 8716{5:-- }{6:match 1 of 9} | 8717]] ) 8718 8719feed ( '<C-E><Esc>' ) 8720end ) 8721 8722-- oldtest: Test_pum_completefuzzycollect() 8723it ( 'fuzzy completion' , function () 8724exec ( [[ 8725set pumwidth=13 8726set completeopt=menu,menuone,fuzzy 8727]] ) 8728 8729feed ( 'S hello helio hero h<C-X><C-P>' ) 8730screen : expect ( [[ 8731hello helio hero hello^ | 8732{1:~ }{n: hero }{1: }| 8733{1:~ }{n: helio }{1: }| 8734{1:~ }{12: hello }{1: }| 8735{1:~ }|*15 8736{5:-- }{6:match 1 of 3} | 8737]] ) 8738 8739feed ( '<Esc>S hello helio hero h<C-X><C-P><C-P>' ) 8740screen : expect ( [[ 8741hello helio hero helio^ | 8742{1:~ }{n: hero }{1: }| 8743{1:~ }{12: helio }{1: }| 8744{1:~ }{n: hello }{1: }| 8745{1:~ }|*15 8746{5:-- }{6:match 2 of 3} | 8747]] ) 8748 8749feed ( '<Esc>S/non_existing_folder<C-X><C-F>' ) 8750screen : expect ( [[ 8751/non_existing_folder^ | 8752{1:~ }|*18 8753{5:-- }{9:Pattern not found} | 8754]] ) 8755feed ( '<C-E><Esc>' ) 8756end ) 8757 8758-- oldtest: Test_pum_highlights_match_with_abbr() 8759it ( 'can highlight matched text with abbr' , function () 8760exec ( [[ 8761func Omni_test(findstart, base) 8762if a:findstart 8763return col(".") 8764endif 8765return { 8766\ 'words': [ 8767\ { 'word': 'foobar', 'abbr': "foobar\t\t!" }, 8768\ { 'word': 'foobaz', 'abbr': "foobaz\t\t!" }, 8769\]} 8770endfunc 8771 8772set omnifunc=Omni_test 8773set completeopt=menuone,noinsert 8774hi PmenuMatchSel guifg=Blue guibg=Grey 8775hi PmenuMatch guifg=Blue guibg=Plum1 8776]] ) 8777feed ( 'i<C-X><C-O>' ) 8778screen : expect ( [[ 8779^ | 8780{12:foobar ! }{1: }| 8781{n:foobaz ! }{1: }| 8782{1:~ }|*16 8783{5:-- }{6:match 1 of 2} | 8784]] ) 8785feed ( 'foo' ) 8786screen : expect ( [[ 8787foo^ | 8788{ms:foo}{12:bar ! }{1: }| 8789{mn:foo}{n:baz ! }{1: }| 8790{1:~ }|*16 8791{5:-- }{6:match 1 of 2} | 8792]] ) 8793 8794feed ( '<C-E><Esc>' ) 8795end ) 8796 8797-- oldtest: Test_pum_user_abbr_hlgroup() 8798it ( 'custom abbr_hlgroup override' , function () 8799exec ( [[ 8800let s:var = 0 8801func CompleteFunc(findstart, base) 8802if a:findstart 8803return 0 8804endif 8805if s:var == 1 8806return { 8807\ 'words': [ 8808\ { 'word': 'aword1', 'abbr_hlgroup': 'StrikeFake' }, 8809\ { 'word': '你好', 'abbr_hlgroup': 'StrikeFake' }, 8810\]} 8811endif 8812return { 8813\ 'words': [ 8814\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' }, 8815\ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', }, 8816\ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' }, 8817\]} 8818endfunc 8819func ChangeVar() 8820let s:var = 1 8821endfunc 8822set completeopt=menu 8823set completefunc=CompleteFunc 8824 8825hi StrikeFake guifg=DarkRed 8826func HlMatch() 8827hi PmenuMatchSel guifg=Blue guibg=Grey gui=underline 8828hi PmenuMatch guifg=Blue guibg=Plum1 gui=underline 8829endfunc 8830]] ) 8831 8832feed ( 'Saw<C-X><C-U>' ) 8833screen : expect ( [[ 8834aword1^ | 8835{ds:aword1}{12: W extra text 1 }{1: }| 8836{n:aword2 W extra text 2 }{1: }| 8837{dn:你好}{n: W extra text 3 }{1: }| 8838{1:~ }|*15 8839{5:-- }{6:match 1 of 3} | 8840]] ) 8841feed ( '<C-E><Esc>' ) 8842 8843command ( 'call HlMatch()' ) 8844 8845feed ( 'Saw<C-X><C-U>' ) 8846screen : expect ( [[ 8847aword1^ | 8848{uds:aw}{ds:ord1}{12: W extra text 1 }{1: }| 8849{umn:aw}{n:ord2 W extra text 2 }{1: }| 8850{dn:你好}{n: W extra text 3 }{1: }| 8851{1:~ }|*15 8852{5:-- }{6:match 1 of 3} | 8853]] ) 8854feed ( '<C-N>' ) 8855screen : expect ( [[ 8856aword2^ | 8857{udn:aw}{dn:ord1}{n: W extra text 1 }{1: }| 8858{ums:aw}{12:ord2 W extra text 2 }{1: }| 8859{dn:你好}{n: W extra text 3 }{1: }| 8860{1:~ }|*15 8861{5:-- }{6:match 2 of 3} | 8862]] ) 8863feed ( '<C-E><Esc>' ) 8864 8865command ( 'call ChangeVar()' ) 8866feed ( 'S<C-X><C-U>' ) 8867screen : expect ( [[ 8868aword1^ | 8869{ds:aword1}{12: }{1: }| 8870{dn:你好}{n: }{1: }| 8871{1:~ }|*16 8872{5:-- }{6:match 1 of 2} | 8873]] ) 8874feed ( '<C-E><Esc>' ) 8875end ) 8876 8877-- oldtest: Test_pum_user_kind_hlgroup() 8878it ( 'custom kind_hlgroup override' , function () 8879exec ( [[ 8880func CompleteFunc( findstart, base ) 8881if a:findstart 8882return 0 8883endif 8884return { 8885\ 'words': [ 8886\ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'variable', 'kind_hlgroup': 'KindVar', 'abbr_hlgroup': 'StrikeFake' }, 8887\ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'function', 'kind_hlgroup': 'KindFunc' }, 8888\ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'class', 'kind_hlgroup': 'KindClass' }, 8889\]} 8890endfunc 8891set completeopt=menu 8892set completefunc=CompleteFunc 8893 8894hi StrikeFake guifg=DarkRed 8895hi KindVar guifg=DarkYellow 8896hi KindFunc guifg=DarkBlue 8897hi KindClass guifg=DarkGreen 8898]] ) 8899 8900feed ( 'S<C-X><C-U>' ) 8901screen : expect ( [[ 8902aword1^ | 8903{ds:aword1}{12: }{110:variable}{12: extra text 1 }{1: }| 8904{n:aword2 }{111:function}{n: extra text 2 }{1: }| 8905{n:你好 }{112:class}{n: extra text 3 }{1: }| 8906{1:~ }|*15 8907{5:-- }{6:match 1 of 3} | 8908]] ) 8909feed ( '<C-E><Esc>' ) 8910end ) 8911 8912-- oldtest: Test_pum_completeitemalign() 8913it ( 'completeitemalign option' , function () 8914screen : try_resize ( 30 , 15 ) 8915exec ( [[ 8916func Omni_test(findstart, base) 8917if a:findstart 8918return col(".") 8919endif 8920return { 8921\ 'words': [ 8922\ { 'word': 'foo', 'kind': 'S', 'menu': 'menu' }, 8923\ { 'word': 'bar', 'kind': 'T', 'menu': 'menu' }, 8924\ { 'word': '你好', 'kind': 'C', 'menu': '中文' }, 8925\]} 8926endfunc 8927 8928func Omni_long(findstart, base) 8929if a:findstart 8930return col(".") 8931endif 8932return { 8933\ 'words': [ 8934\ { 'word': 'loooong_foo', 'kind': 'S', 'menu': 'menu' }, 8935\ { 'word': 'loooong_bar', 'kind': 'T', 'menu': 'menu' }, 8936\]} 8937endfunc 8938set omnifunc=Omni_test 8939]] ) 8940-- T1 8941command ( 'set cia=abbr,kind,menu' ) 8942feed ( 'S<C-X><C-O>' ) 8943screen : expect ( [[ 8944foo^ | 8945{12:foo S menu }{1: }| 8946{n:bar T menu }{1: }| 8947{n:你好 C 中文 }{1: }| 8948{1:~ }|*10 8949{5:-- }{6:match 1 of 3} | 8950]] ) 8951feed ( '<C-E><ESC>' ) 8952-- T2 8953command ( 'set cia=abbr,menu,kind' ) 8954feed ( 'S<C-X><C-O>' ) 8955screen : expect ( [[ 8956foo^ | 8957{12:foo menu S }{1: }| 8958{n:bar menu T }{1: }| 8959{n:你好 中文 C }{1: }| 8960{1:~ }|*10 8961{5:-- }{6:match 1 of 3} | 8962]] ) 8963feed ( '<C-E><ESC>' ) 8964-- T3 8965command ( 'set cia=kind,abbr,menu' ) 8966feed ( 'S<C-X><C-O>' ) 8967screen : expect ( [[ 8968foo^ | 8969{12:S foo menu }{1: }| 8970{n:T bar menu }{1: }| 8971{n:C 你好 中文 }{1: }| 8972{1:~ }|*10 8973{5:-- }{6:match 1 of 3} | 8974]] ) 8975feed ( '<C-E><ESC>' ) 8976-- T4 8977command ( 'set cia=kind,menu,abbr' ) 8978feed ( 'S<C-X><C-O>' ) 8979screen : expect ( [[ 8980foo^ | 8981{12:S menu foo }{1: }| 8982{n:T menu bar }{1: }| 8983{n:C 中文 你好 }{1: }| 8984{1:~ }|*10 8985{5:-- }{6:match 1 of 3} | 8986]] ) 8987feed ( '<C-E><ESC>' ) 8988-- T5 8989command ( 'set cia=menu,abbr,kind' ) 8990feed ( 'S<C-X><C-O>' ) 8991screen : expect ( [[ 8992foo^ | 8993{12:menu foo S }{1: }| 8994{n:menu bar T }{1: }| 8995{n:中文 你好 C }{1: }| 8996{1:~ }|*10 8997{5:-- }{6:match 1 of 3} | 8998]] ) 8999feed ( '<C-E><ESC>' ) 9000-- T6 9001command ( 'set cia=menu,kind,abbr' ) 9002feed ( 'S<C-X><C-O>' ) 9003screen : expect ( [[ 9004foo^ | 9005{12:menu S foo }{1: }| 9006{n:menu T bar }{1: }| 9007{n:中文 C 你好 }{1: }| 9008{1:~ }|*10 9009{5:-- }{6:match 1 of 3} | 9010]] ) 9011feed ( '<C-E><ESC>' ) 9012-- T7 9013command ( 'set cia&' ) 9014feed ( 'S<C-X><C-O>' ) 9015screen : expect ( [[ 9016foo^ | 9017{12:foo S menu }{1: }| 9018{n:bar T menu }{1: }| 9019{n:你好 C 中文 }{1: }| 9020{1:~ }|*10 9021{5:-- }{6:match 1 of 3} | 9022]] ) 9023feed ( '<C-E><ESC>' ) 9024 9025-- Test_pum_completeitemalign_07 9026command ( 'set cia=menu,kind,abbr columns=12 cmdheight=2 omnifunc=Omni_long' ) 9027feed ( 'S<C-X><C-O>' ) 9028screen : expect ( [[ 9029loooong_foo^ | 9030{12:menu S looo>}| 9031{n:menu T looo>}| 9032{1:~ }|*10 9033| 9034{5:--} | 9035]] ) 9036feed ( '<C-E><ESC>' ) 9037end ) 9038 9039-- oldtest: Test_pum_matchins_highlight() 9040it ( 'with ComplMatchIns highlight' , function () 9041exec ( [[ 9042let g:change = 0 9043func Omni_test(findstart, base) 9044if a:findstart 9045return col(".") 9046endif 9047if g:change == 0 9048return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}] 9049endif 9050return [#{word: "foo", info: "info"}, #{word: "bar"}, #{word: "你好"}] 9051endfunc 9052set completeopt-=popup completeopt+=preview 9053set omnifunc=Omni_test 9054hi ComplMatchIns guifg=red 9055]] ) 9056 9057feed ( 'Sαβγ <C-X><C-O>' ) 9058screen : expect ( [[ 9059αβγ {19:foo}^ | 9060{1:~ }{12: foo }{1: }| 9061{1:~ }{n: bar }{1: }| 9062{1:~ }{n: 你好 }{1: }| 9063{1:~ }|*15 9064{5:-- }{6:match 1 of 3} | 9065]] ) 9066feed ( '<C-E><Esc>' ) 9067 9068feed ( 'Sαβγ <C-X><C-O><C-N>' ) 9069screen : expect ( [[ 9070αβγ {19:bar}^ | 9071{1:~ }{n: foo }{1: }| 9072{1:~ }{12: bar }{1: }| 9073{1:~ }{n: 你好 }{1: }| 9074{1:~ }|*15 9075{5:-- }{6:match 2 of 3} | 9076]] ) 9077feed ( '<C-E><Esc>' ) 9078 9079feed ( 'Sαβγ <C-X><C-O><C-N><C-N>' ) 9080screen : expect ( [[ 9081αβγ {19:你好}^ | 9082{1:~ }{n: foo }{1: }| 9083{1:~ }{n: bar }{1: }| 9084{1:~ }{12: 你好 }{1: }| 9085{1:~ }|*15 9086{5:-- }{6:match 3 of 3} | 9087]] ) 9088feed ( '<C-E><Esc>' ) 9089 9090-- restore after accept 9091feed ( 'Sαβγ <C-X><C-O><C-Y>' ) 9092screen : expect ( [[ 9093αβγ foo^ | 9094{1:~ }|*18 9095{5:-- INSERT --} | 9096]] ) 9097feed ( '<Esc>' ) 9098 9099-- restore after cancel completion 9100feed ( 'Sαβγ <C-X><C-O><Space>' ) 9101screen : expect ( [[ 9102αβγ foo ^ | 9103{1:~ }|*18 9104{5:-- INSERT --} | 9105]] ) 9106feed ( '<Esc>' ) 9107 9108-- text after the inserted text shouldn't be highlighted 9109feed ( '0ea <C-X><C-O>' ) 9110screen : expect ( [[ 9111αβγ {19:foo}^ foo | 9112{1:~ }{12: foo }{1: }| 9113{1:~ }{n: bar }{1: }| 9114{1:~ }{n: 你好 }{1: }| 9115{1:~ }|*15 9116{5:-- }{6:match 1 of 3} | 9117]] ) 9118feed ( '<C-P>' ) 9119screen : expect ( [[ 9120αβγ ^ foo | 9121{1:~ }{n: foo }{1: }| 9122{1:~ }{n: bar }{1: }| 9123{1:~ }{n: 你好 }{1: }| 9124{1:~ }|*15 9125{5:-- }{19:Back at original} | 9126]] ) 9127feed ( '<C-P>' ) 9128screen : expect ( [[ 9129αβγ {19:你好}^ foo | 9130{1:~ }{n: foo }{1: }| 9131{1:~ }{n: bar }{1: }| 9132{1:~ }{12: 你好 }{1: }| 9133{1:~ }|*15 9134{5:-- }{6:match 3 of 3} | 9135]] ) 9136feed ( '<C-Y>' ) 9137screen : expect ( [[ 9138αβγ 你好^ foo | 9139{1:~ }|*18 9140{5:-- INSERT --} | 9141]] ) 9142feed ( '<Esc>' ) 9143 9144feed ( ':let g:change=1<CR>S<C-X><C-O>' ) 9145screen : expect ( [[ 9146info | 9147{1:~ }|*2 9148{2:[Scratch] [Preview][-] }| 9149{19:foo}^ | 9150{12:foo }{1: }| 9151{n:bar }{1: }| 9152{n:你好 }{1: }| 9153{1:~ }|*10 9154{3:[No Name] [+] }| 9155{5:-- }{6:match 1 of 3} | 9156]] ) 9157feed ( '<Esc>' ) 9158end ) 9159 9160-- oldtest: Test_pum_matchins_highlight_combine() 9161it ( 'with ComplMatchIns, Normal and CursorLine highlights' , function () 9162exec ( [[ 9163func Omni_test(findstart, base) 9164if a:findstart 9165return col(".") 9166endif 9167return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}] 9168endfunc 9169set completeopt-=popup completeopt+=preview 9170" Avoid unwanted results in case local workspace has a "tags" file. 9171set complete-=t 9172set omnifunc=Omni_test 9173hi Normal guibg=blue 9174hi CursorLine guibg=green guifg=white 9175set cursorline 9176call setline(1, 'aaa bbb') 9177]] ) 9178 9179-- when ComplMatchIns is not set, CursorLine applies normally 9180feed ( '0ea <C-X><C-O>' ) 9181screen : expect ( [[ 9182{101:aaa foo^ bbb }| 9183{1:~ }{12: foo }{1: }| 9184{1:~ }{n: bar }{1: }| 9185{1:~ }{n: 你好 }{1: }| 9186{1:~ }|*15 9187{5:-- }{6:match 1 of 3} | 9188]] ) 9189feed ( '<C-E>' ) 9190screen : expect ( [[ 9191{101:aaa ^ bbb }| 9192{1:~ }|*18 9193{5:-- INSERT --} | 9194]] ) 9195feed ( '<BS><Esc>' ) 9196 9197-- when ComplMatchIns is set, it is applied over CursorLine 9198command ( 'hi ComplMatchIns guifg=Yellow' ) 9199feed ( '0ea <C-X><C-O>' ) 9200screen : expect ( [[ 9201{101:aaa }{100:foo}{101:^ bbb }| 9202{1:~ }{12: foo }{1: }| 9203{1:~ }{n: bar }{1: }| 9204{1:~ }{n: 你好 }{1: }| 9205{1:~ }|*15 9206{5:-- }{6:match 1 of 3} | 9207]] ) 9208feed ( '<C-P>' ) 9209screen : expect ( [[ 9210{101:aaa ^ bbb }| 9211{1:~ }{n: foo }{1: }| 9212{1:~ }{n: bar }{1: }| 9213{1:~ }{n: 你好 }{1: }| 9214{1:~ }|*15 9215{5:-- }{19:Back at original} | 9216]] ) 9217feed ( '<C-P>' ) 9218screen : expect ( [[ 9219{101:aaa }{100:你好}{101:^ bbb }| 9220{1:~ }{n: foo }{1: }| 9221{1:~ }{n: bar }{1: }| 9222{1:~ }{12: 你好 }{1: }| 9223{1:~ }|*15 9224{5:-- }{6:match 3 of 3} | 9225]] ) 9226feed ( '<C-E>' ) 9227screen : expect ( [[ 9228{101:aaa ^ bbb }| 9229{1:~ }|*18 9230{5:-- INSERT --} | 9231]] ) 9232feed ( '<Esc>' ) 9233 9234-- Does not highlight the compl leader 9235command ( 'set completeopt+=menuone,noselect' ) 9236feed ( 'S<C-X><C-O>' ) 9237local pum_start =[[ 9238{101:^ }| 9239{n:foo }{1: }| 9240{n:bar }{1: }| 9241{n:你好 }{1: }| 9242{1:~ }|*15 9243{5:-- }{19:Back at original} | 9244]] 9245screen : expect ( pum_start ) 9246feed ( 'f<C-N>' ) 9247screen : expect ( [[ 9248{101:f}{100:oo}{101:^ }| 9249{12:foo }{1: }| 9250{1:~ }|*17 9251{5:-- }{6:match 1 of 3} | 9252]] ) 9253feed ( '<C-E><ESC>' ) 9254 9255command ( 'set completeopt+=fuzzy' ) 9256feed ( 'S<C-X><C-O>' ) 9257screen : expect ( pum_start ) 9258feed ( 'f<C-N>' ) 9259screen : expect ( [[ 9260{101:foo^ }| 9261{12:foo }{1: }| 9262{1:~ }|*17 9263{5:-- }{6:match 1 of 3} | 9264]] ) 9265feed ( '<C-E><Esc>' ) 9266 9267command ( 'set completeopt-=fuzzy' ) 9268feed ( 'Sf<C-N>' ) 9269screen : expect ( [[ 9270{101:f^ }| 9271{1:~ }|*18 9272{5:-- }{9:Pattern not found} | 9273]] ) 9274feed ( '<C-E><Esc>' ) 9275end ) 9276 9277-- oldtest: Test_pum_complete_with_special_characters() 9278it ( 'multi-line completion' , function () 9279exec ( [[ 9280func Omni_test(findstart, base) 9281if a:findstart 9282return col(".") 9283endif 9284return [#{word: "func ()\n\t\nend", abbr: "function ()",}, #{word: "foobar"}, #{word: "你好\n\t\n我好"}] 9285endfunc 9286set omnifunc=Omni_test 9287inoremap <F5> <Cmd>call complete(col('.'), [ "my\n\tmulti\nline", "my\n\t\tmulti\nline" ])<CR> 9288]] ) 9289 9290feed ( 'S<C-X><C-O>' ) 9291screen : expect ( [[ 9292func () | 9293| 9294end^ | 9295{12:function () }{1: }| 9296{n:foobar }{1: }| 9297{n:你好^@ ^@我好 }{1: }| 9298{1:~ }|*13 9299{5:-- }{6:match 1 of 3} | 9300]] ) 9301 9302feed ( '<C-N>' ) 9303screen : expect ( [[ 9304foobar^ | 9305{n:function () }{1: }| 9306{12:foobar }{1: }| 9307{n:你好^@ ^@我好 }{1: }| 9308{1:~ }|*15 9309{5:-- }{6:match 2 of 3} | 9310]] ) 9311feed ( '<C-E><ESC>' ) 9312 9313feed ( 'Shello hero<ESC>hhhhha<C-X><C-O>' ) 9314screen : expect ( [[ 9315hello func () | 9316| 9317end^ hero | 9318{1:~ }{12: function () }{1: }| 9319{1:~ }{n: foobar }{1: }| 9320{1:~ }{n: 你好^@ ^@我好 }{1: }| 9321{1:~ }|*13 9322{5:-- }{6:match 1 of 3} | 9323]] ) 9324 9325feed ( '<C-N>' ) 9326screen : expect ( [[ 9327hello foobar^ hero | 9328{1:~ }{n: function () }{1: }| 9329{1:~ }{12: foobar }{1: }| 9330{1:~ }{n: 你好^@ ^@我好 }{1: }| 9331{1:~ }|*15 9332{5:-- }{6:match 2 of 3} | 9333]] ) 9334 9335feed ( '<C-N>' ) 9336screen : expect ( [[ 9337hello 你好 | 9338| 9339我好^ hero | 9340{1:~ }{n: function () }{1: }| 9341{1:~ }{n: foobar }{1: }| 9342{1:~ }{12: 你好^@ ^@我好 }{1: }| 9343{1:~ }|*13 9344{5:-- }{6:match 3 of 3} | 9345]] ) 9346 9347feed ( '<C-N>' ) 9348screen : expect ( [[ 9349hello ^ hero | 9350{1:~ }{n: function () }{1: }| 9351{1:~ }{n: foobar }{1: }| 9352{1:~ }{n: 你好^@ ^@我好 }{1: }| 9353{1:~ }|*15 9354{5:-- }{19:Back at original} | 9355]] ) 9356feed ( '<C-E><ESC>' ) 9357 9358command ( ':hi ComplMatchIns guifg=red' ) 9359feed ( 'S<C-X><C-O>' ) 9360screen : expect ( [[ 9361{19:func ()} | 9362{19: } | 9363{19:end}^ | 9364{12:function () }{1: }| 9365{n:foobar }{1: }| 9366{n:你好^@ ^@我好 }{1: }| 9367{1:~ }|*13 9368{5:-- }{6:match 1 of 3} | 9369]] ) 9370feed ( '<C-E><ESC>' ) 9371 9372feed ( 'Shello hero<ESC>hhhhha<C-X><C-O>' ) 9373screen : expect ( [[ 9374hello {19:func ()} | 9375{19: } | 9376{19:end^ }hero | 9377{1:~ }{12: function () }{1: }| 9378{1:~ }{n: foobar }{1: }| 9379{1:~ }{n: 你好^@ ^@我好 }{1: }| 9380{1:~ }|*13 9381{5:-- }{6:match 1 of 3} | 9382]] ) 9383feed ( '<C-E><ESC>' ) 9384 9385command ( 'setlocal autoindent shiftwidth=2 tabstop=2' ) 9386feed ( 'Slocal a = <C-X><C-O>' ) 9387screen : expect ( [[ 9388local a = {19:func ()} | 9389{19: } | 9390{19:end}^ | 9391{1:~ }{12: function () }{1: }| 9392{1:~ }{n: foobar }{1: }| 9393{1:~ }{n: 你好^@ ^@我好 }{1: }| 9394{1:~ }|*13 9395{5:-- }{6:match 1 of 3} | 9396]] ) 9397 9398feed ( '<C-Y>' ) 9399screen : expect ( [[ 9400local a = {19:func ()} | 9401{19: } | 9402end^ | 9403{1:~ }|*16 9404{5:-- INSERT --} | 9405]] ) 9406 9407feed ( '<ESC>kAlocal b = <C-X><C-O>' ) 9408screen : expect ( [[ 9409local a = {19:func ()} | 9410local b = {19:func ()} | 9411{19: } | 9412{19: end}^ | 9413end {12: function () } | 9414{1:~ }{n: foobar }{1: }| 9415{1:~ }{n: 你好^@ ^@我好 }{1: }| 9416{1:~ }|*12 9417{5:-- }{6:match 1 of 3} | 9418]] ) 9419 9420feed ( '<C-Y>' ) 9421screen : expect ( [[ 9422local a = {19:func ()} | 9423local b = {19:func ()} | 9424{19: } | 9425end^ | 9426end | 9427{1:~ }|*14 9428{5:-- INSERT --} | 9429]] ) 9430 9431feed ( '<Esc>ggVGd' ) 9432command ( 'filetype indent on' ) 9433command ( 'setlocal noautoindent shiftwidth& tabstop&' ) 9434command ( 'setlocal ft=lua' ) 9435feed ( 'S<F5>' ) 9436screen : expect ( [[ 9437{19:my} | 9438{19: multi} | 9439{19:line}^ | 9440{12:my^@ multi^@line }{1: }| 9441{n:my^@ multi^@line }{1: }| 9442{1:~ }|*14 9443{5:-- INSERT --} | 9444]] ) 9445end ) 9446 9447-- oldtest: Test_pum_clear_when_switch_tab_or_win() 9448it ( 'is cleared when switching tab or win' , function () 9449screen : try_resize ( 55 , 20 ) 9450exec ( [[ 9451inoremap <F4> <Cmd>wincmd w<CR> 9452inoremap <F5> <Cmd>tabnext<CR> 9453]] ) 9454 9455command ( 'tabe' ) 9456feed ( 'Aaa aaa <C-X><C-N>' ) 9457screen : expect ( [[ 9458{24: [No Name] }{5: + [No Name] }{2: }{24:X}| 9459aa aaa aa^ | 9460{1:~ }{12: aa }{1: }| 9461{1:~ }{n: aaa }{1: }| 9462{1:~ }|*15 9463{5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 9464]] ) 9465feed ( '<F5>' ) 9466screen : expect ( [[ 9467{5: [No Name] }{24: + [No Name] }{2: }{24:X}| 9468^ | 9469{1:~ }|*17 9470{5:-- INSERT --} | 9471]] ) 9472feed ( '<Esc>' ) 9473command ( 'tabclose!' ) 9474 9475command ( 'vnew win_b' ) 9476feed ( 'Abb bbb <C-X><C-N>' ) 9477screen : expect ( [[ 9478bb bbb bb^ │aa aaa aa | 9479{1:~ }{12: bb }{1: }│{1:~ }| 9480{1:~ }{n: bbb }{1: }│{1:~ }| 9481{1:~ }│{1:~ }|*15 9482{3:win_b [+] }{2:[No Name] [+] }| 9483{5:-- Keyword Local completion (^N^P) }{6:match 1 of 2} | 9484]] ) 9485feed ( '<F4>' ) 9486screen : expect ( [[ 9487bb bbb bb │aa aaa a^a | 9488{1:~ }│{1:~ }|*17 9489{2:win_b [+] }{3:[No Name] [+] }| 9490{5:-- INSERT --} | 9491]] ) 9492end ) 9493end 9494 9495describe ( "'pumborder'" , function () 9496before_each ( function () 9497screen : try_resize ( 30 , 11 ) 9498exec ( [[ 9499let g:list = [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}] 9500funct Omni_test(findstart, base) 9501if a:findstart 9502return col(".") - 1 9503endif 9504return g:list 9505endfunc 9506hi link PmenuBorder FloatBorder 9507set omnifunc=Omni_test 9508set completeopt-=preview 9509set pumborder=rounded 9510]] ) 9511end ) 9512 9513it ( 'can set border' , function () 9514feed ( 'Gi<C-x><C-o>' ) 9515if multigrid then 9516screen : expect ( { 9517grid =[[ 9518## grid 1 9519[2:------------------------------]|*10 9520[3:------------------------------]| 9521## grid 2 9522one^ | 9523{1:~ }|*9 9524## grid 3 9525{5:-- }{6:match 1 of 3} | 9526## grid 4 9527{n:1info}| 9528## grid 5 9529╭───────────────╮| 9530│{12:one }│| 9531│{n:two }│| 9532│{n:three }│| 9533╰───────────────╯| 9534]] , 9535win_pos ={ 9536[ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =30 , win =1000 } , 9537} , 9538float_pos ={ 9539[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 2 , 1 , 0 } , 9540[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 17 , true , 50 , 1 , 1 , 17 } , 9541} , 9542} ) 9543else 9544screen : expect ( [[ 9545one^ | 9546╭───────────────╮{n:1info}{1: }| 9547│{12:one }│{1: }| 9548│{n:two }│{1: }| 9549│{n:three }│{1: }| 9550╰───────────────╯{1: }| 9551{1:~ }|*4 9552{5:-- }{6:match 1 of 3} | 9553]] ) 9554end 9555 9556-- avoid out of screen 9557feed (( 'a' ): rep ( 25 ) .. '<C-x><C-o>' ) 9558if multigrid then 9559screen : expect ( { 9560grid =[[ 9561## grid 1 9562[2:------------------------------]|*10 9563[3:------------------------------]| 9564## grid 2 9565oneaaaaaaaaaaaaaaaaaaaaaaaaaon| 9566e^ | 9567{1:~ }|*8 9568## grid 3 9569{5:-- }{6:match 1 of 3} | 9570## grid 4 9571{n:1info}| 9572## grid 5 9573╭─────────────────╮| 9574│{12: one }│| 9575│{n: two }│| 9576│{n: three }│| 9577╰─────────────────╯| 9578]] , 9579win_pos ={ 9580[ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =30 , win =1000 } , 9581} , 9582float_pos ={ 9583[ 5 ] ={ - 1 , 'NW' , 2 , 2 , 11 , false , 100 , 2 , 2 , 11 } , 9584[ 4 ] ={ 1001 , 'NW' , 1 , 2 , 6 , true , 50 , 1 , 2 , 6 } , 9585} , 9586} ) 9587else 9588screen : expect ( [[ 9589oneaaaaaaaaaaaaaaaaaaaaaaaaaon| 9590e^ | 9591{1:~ }{n:1info}╭─────────────────╮| 9592{1:~ }│{12: one }│| 9593{1:~ }│{n: two }│| 9594{1:~ }│{n: three }│| 9595{1:~ }╰─────────────────╯| 9596{1:~ }|*3 9597{5:-- }{6:match 1 of 3} | 9598]] ) 9599end 9600end ) 9601 9602it ( 'adjust to above when the below row + border out of win height' , function () 9603command ( 'set completeopt+=menuone,noselect' ) 9604feed ( '<ESC>Stwo' .. ( '<CR>' ): rep ( 6 ) .. 'tw<C-N>' ) 9605if multigrid then 9606screen : expect ( { 9607grid =[[ 9608## grid 1 9609[2:------------------------------]|*10 9610[3:------------------------------]| 9611## grid 2 9612two | 9613|*5 9614tw^ | 9615{1:~ }|*3 9616## grid 3 9617{5:-- }{19:Back at original} | 9618## grid 4 9619╭───────────────╮| 9620│{n:two }│| 9621╰───────────────╯| 9622]] , 9623win_pos ={ 9624[ 2 ] ={ 9625height =10 , 9626startcol =0 , 9627startrow =0 , 9628width =30 , 9629win =1000 , 9630} , 9631} , 9632float_pos ={ 9633[ 4 ] ={ - 1 , 'SW' , 2 , 4 , 0 , false , 100 , 1 , 3 , 0 } , 9634} , 9635win_viewport ={ 9636[ 2 ] ={ 9637win =1000 , 9638topline =0 , 9639botline =8 , 9640curline =6 , 9641curcol =2 , 9642linecount =7 , 9643sum_scroll_delta =0 , 9644} , 9645} , 9646win_viewport_margins ={ 9647[ 2 ] ={ 9648bottom =0 , 9649left =0 , 9650right =0 , 9651top =0 , 9652win =1000 , 9653} , 9654} , 9655} ) 9656else 9657screen : expect ( [[ 9658two | 9659|*2 9660╭───────────────╮ | 9661│{n:two }│ | 9662╰───────────────╯ | 9663tw^ | 9664{1:~ }|*3 9665{5:-- }{19:Back at original} | 9666]] ) 9667end 9668end ) 9669 9670it ( "'pumborder' on cmdline and scrollbar rendering" , function () 9671command ( 'set wildoptions=pum' ) 9672feed ( ':t<TAB>' ) 9673if multigrid then 9674screen : expect ( { 9675grid =[[ 9676## grid 1 9677[2:------------------------------]|*10 9678[3:------------------------------]| 9679## grid 2 9680| 9681{1:~ }|*9 9682## grid 3 9683:t^ | 9684## grid 4 9685╭────────────────╮| 9686│{12: t }{c: }| 9687│{n: tNext }│| 9688│{n: tab }│| 9689│{n: tabNext }│| 9690│{n: tabclose }│| 9691│{n: tabdo }│| 9692│{n: tabedit }│| 9693│{n: tabfind }│| 9694╰────────────────╯| 9695]] , 9696win_pos ={ 9697[ 2 ] ={ height =10 , startcol =0 , startrow =0 , width =30 , win =1000 } , 9698} , 9699float_pos ={ 9700[ 4 ] ={ - 1 , 'SW' , 1 , 8 , 0 , false , 250 , 2 , 0 , 0 } , 9701} , 9702} ) 9703else 9704screen : expect ( [[ 9705╭────────────────╮ | 9706│{12: t }{c: }{1: }| 9707│{n: tNext }│{1: }| 9708│{n: tab }│{1: }| 9709│{n: tabNext }│{1: }| 9710│{n: tabclose }│{1: }| 9711│{n: tabdo }│{1: }| 9712│{n: tabedit }│{1: }| 9713│{n: tabfind }│{1: }| 9714╰────────────────╯{1: }| 9715:t^ | 9716]] ) 9717end 9718 9719feed (( '<C-N>' ): rep ( 20 )) 9720if not multigrid then 9721screen : expect ( [[ 9722╭────────────────╮ | 9723│{n: tabs }│{1: }| 9724│{n: tag }│{1: }| 9725│{n: tags }│{1: }| 9726│{n: tcd }{c: }{1: }| 9727│{12: tchdir }│{1: }| 9728│{n: tcl }│{1: }| 9729│{n: tcldo }│{1: }| 9730│{n: tclfile }│{1: }| 9731╰────────────────╯{1: }| 9732:tchdir^ | 9733]] ) 9734end 9735feed (( '<C-P>' ): rep ( 20 )) 9736if not multigrid then 9737screen : expect ( [[ 9738╭────────────────╮ | 9739│{12: t }{c: }{1: }| 9740│{n: tNext }│{1: }| 9741│{n: tab }│{1: }| 9742│{n: tabNext }│{1: }| 9743│{n: tabclose }│{1: }| 9744│{n: tabdo }│{1: }| 9745│{n: tabedit }│{1: }| 9746│{n: tabfind }│{1: }| 9747╰────────────────╯{1: }| 9748:t^ | 9749]] ) 9750end 9751end ) 9752 9753it ( 'reduce pum height when height is not enough' , function () 9754command ( 'set lines=7 laststatus=2' ) 9755feed ( 'S<C-x><C-o>' ) 9756if multigrid then 9757screen : expect ( { 9758grid =[[ 9759## grid 1 9760[2:------------------------------]|*5 9761{3:[No Name] [+] }| 9762[3:------------------------------]| 9763## grid 2 9764one^ | 9765{1:~ }|*4 9766## grid 3 9767{5:-- }{6:match 1 of 3} | 9768## grid 4 9769╭───────────────╮| 9770│{12:one }{c: }| 9771╰───────────────╯| 9772]] , 9773win_pos ={ 9774[ 2 ] ={ height =5 , startcol =0 , startrow =0 , width =30 , win =1000 } , 9775} , 9776float_pos ={ 9777[ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } , 9778} , 9779} ) 9780else 9781screen : expect ( [[ 9782one^ | 9783╭───────────────╮{1: }| 9784│{12:one }{c: }{1: }| 9785╰───────────────╯{1: }| 9786{1:~ }| 9787{3:[No Name] [+] }| 9788{5:-- }{6:match 1 of 3} | 9789]] ) 9790end 9791end ) 9792it ( 'custom pumborder characters' , function () 9793command ( 'set pumborder=+,+,=,+,+,-,+,+' ) 9794feed ( 'S<C-x><C-o>' ) 9795if not multigrid then 9796screen : expect ( [[ 9797one^ | 9798++++++++++++++++={n:1info}{1: }| 9799+{12:one }+{1: }| 9800+{n:two }+{1: }| 9801+{n:three }+{1: }| 9802+---------------+{1: }| 9803{1:~ }|*4 9804{5:-- }{6:match 1 of 3} | 9805]] ) 9806end 9807end ) 9808it ( "'pumborder' with shadow" , function () 9809command ( 'set pumborder=shadow' ) 9810insert ( 'line1\nline2line2line2line2\nline3\nline4line4line4\nline5line5' ) 9811feed ( 'ggO<C-x><C-o>' ) 9812if multigrid then 9813screen : expect ( { 9814grid =[[ 9815## grid 1 9816[2:------------------------------]|*10 9817[3:------------------------------]| 9818## grid 2 9819one^ | 9820line1 | 9821line2line2line2line2 | 9822line3 | 9823line4line4line4 | 9824line5line5 | 9825{1:~ }|*4 9826## grid 3 9827{5:-- }{6:match 1 of 3} | 9828## grid 4 9829{n:1info}| 9830## grid 5 9831{12:one }{114: }| 9832{n:two }{115: }| 9833{n:three }{115: }| 9834{114: }{115: }| 9835]] , 9836win_pos ={ 9837[ 2 ] ={ 9838height =10 , 9839startcol =0 , 9840startrow =0 , 9841width =30 , 9842win =1000 , 9843} , 9844} , 9845float_pos ={ 9846[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 2 , 1 , 0 } , 9847[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 16 , true , 50 , 1 , 1 , 16 } , 9848} , 9849} ) 9850else 9851screen : expect ( [[ 9852one^ | 9853{12:one }{116: }{n:1info} | 9854{n:two }{117:l}ine2 | 9855{n:three }{117: } | 9856{116:l}{117:ine4line4line4 } | 9857line5line5 | 9858{1:~ }|*4 9859{5:-- }{6:match 1 of 3} | 9860]] ) 9861end 9862command ( 'set pumheight=2' ) 9863feed ( '<C-x><C-O>' ) 9864if multigrid then 9865screen : expect ( { 9866grid =[[ 9867## grid 1 9868[2:------------------------------]|*10 9869[3:------------------------------]| 9870## grid 2 9871oneone^ | 9872line1 | 9873line2line2line2line2 | 9874line3 | 9875line4line4line4 | 9876line5line5 | 9877{1:~ }|*4 9878## grid 3 9879{5:-- }{6:match 1 of 3} | 9880## grid 4 9881{n:1info}| 9882## grid 5 9883{12: one }{c: }{114: }| 9884{n: two }{12: }{115: }| 9885{114: }{115: }| 9886]] , 9887win_pos ={ 9888[ 2 ] ={ 9889height =10 , 9890startcol =0 , 9891startrow =0 , 9892width =30 , 9893win =1000 , 9894} , 9895} , 9896float_pos ={ 9897[ 5 ] ={ - 1 , 'NW' , 2 , 1 , 2 , false , 100 , 2 , 1 , 2 } , 9898[ 4 ] ={ 1001 , 'NW' , 1 , 1 , 19 , true , 50 , 1 , 1 , 19 } , 9899} , 9900} ) 9901else 9902screen : expect ( [[ 9903oneone^ | 9904li{12: one }{c: }{116: }{n:info} | 9905li{n: two }{12: }{117:2} | 9906li{116:n}{117:e3 } | 9907line4line4line4 | 9908line5line5 | 9909{1:~ }|*4 9910{5:-- }{6:match 1 of 3} | 9911]] ) 9912end 9913end ) 9914it ( "'pumborder' with none #36207" , function () 9915command ( 'set wildoptions=pum pumborder=none' ) 9916feed ( ':<TAB>' ) 9917if multigrid then 9918screen : expect ( { 9919grid =[[ 9920## grid 1 9921[2:------------------------------]|*10 9922[3:------------------------------]| 9923## grid 2 9924| 9925{1:~ }|*9 9926## grid 3 9927:!^ | 9928## grid 4 9929{12: ! }{c: }| 9930{n: # }{12: }| 9931{n: & }{12: }| 9932{n: < }{12: }| 9933{n: = }{12: }| 9934{n: > }{12: }| 9935{n: @ }{12: }| 9936{n: Next }{12: }| 9937{n: abbreviate }{12: }| 9938{n: abclear }{12: }| 9939]] , 9940win_pos ={ 9941[ 2 ] ={ 9942height =10 , 9943startcol =0 , 9944startrow =0 , 9945width =30 , 9946win =1000 , 9947} , 9948} , 9949float_pos ={ 9950[ 4 ] ={ - 1 , 'SW' , 1 , 10 , 0 , false , 250 , 2 , 0 , 0 } , 9951} , 9952} ) 9953else 9954screen : expect ( [[ 9955{12: ! }{c: } | 9956{n: # }{12: }{1: }| 9957{n: & }{12: }{1: }| 9958{n: < }{12: }{1: }| 9959{n: = }{12: }{1: }| 9960{n: > }{12: }{1: }| 9961{n: @ }{12: }{1: }| 9962{n: Next }{12: }{1: }| 9963{n: abbreviate }{12: }{1: }| 9964{n: abclear }{12: }{1: }| 9965:!^ | 9966]] ) 9967end 9968feed ( '<ESC>:set pumheight=2<CR>Gi<C-X><C-O>' ) 9969if not multigrid then 9970screen : expect ( [[ 9971one^ | 9972{12:one }{c: }{n:1info}{1: }| 9973{n:two }{12: }{1: }| 9974{1:~ }|*7 9975{5:-- }{6:match 1 of 3} | 9976]] ) 9977end 9978end ) 9979it ( "no crash when 'pumborder' set #36337" , function () 9980command ( 'set autocomplete pumborder=rounded complete=o cot=popup,menuone,noinsert' ) 9981command ( 'set columns=50 lines=20' ) 9982exec_lua ( function () 9983local list1 ={ 9984{ abbr ='array: ' , info ='' , kind ='Field' , word ='array: ' } , 9985{ abbr ='arrays: ' , info ='' , kind ='Field' , word ='arrays: ' } , 9986} 9987local list2 ={ 9988{ abbr ='match ' , info ='' , kind ='Keyword' , word ='match ' } , 9989{ abbr ='throw ' , info ='' , kind ='Keyword' , word ='throw ' } , 9990{ abbr ='array: ' , info ='' , kind ='Field' , word ='array: ' } , 9991{ abbr ='arrays: ' , info ='' , kind ='Field' , word ='arrays: ' } , 9992} 9993_G . fake_omni =function ( _ , _ ) 9994local line =vim . api . nvim_get_current_line () 9995if line : find ( '%s%)$' ) then 9996vim . schedule ( function () 9997vim . fn . complete ( 25 , list1 ) 9998vim . fn . complete ( 25 , list2 ) 9999end ) 10000end 10001return - 2 10002end 10003vim . opt . omnifunc ='v:lua.fake_omni' 10004vim . api . nvim_buf_set_lines ( 0 , 0 , - 1 , true , { '<?php' , 'array_intersect_key($x)' } ) 10005vim . cmd . normal ( 'G$' ) 10006end ) 10007feed ( 'i, ' ) 10008poke_eventloop () 10009assert_alive () 10010eq ( { 4 , 1 } , { # fn . complete_info ( { 'items' } ). items , fn . pumvisible () } ) 10011end ) 10012 10013it ( "works with 'pummaxwidth'" , function () 10014exec ( [[ 10015set pummaxwidth=10 10016set cot+=menuone 10017let g:list = [#{word: repeat('fo', 10)}] 10018]] ) 10019feed ( 'S<C-x><C-o>' ) 10020if multigrid then 10021screen : expect ( { 10022grid =[[ 10023## grid 1 10024[2:------------------------------]|*10 10025[3:------------------------------]| 10026## grid 2 10027fofofofofofofofofofo^ | 10028{1:~ }|*9 10029## grid 3 10030{5:-- The only match} | 10031## grid 4 10032╭──────────╮| 10033│{12:fofofofof>}│| 10034╰──────────╯| 10035]] , 10036float_pos ={ 10037[ 4 ] ={ - 1 , 'NW' , 2 , 1 , 0 , false , 100 , 1 , 1 , 0 } , 10038} , 10039} ) 10040else 10041screen : expect ( [[ 10042fofofofofofofofofofo^ | 10043╭──────────╮{1: }| 10044│{12:fofofofof>}│{1: }| 10045╰──────────╯{1: }| 10046{1:~ }|*6 10047{5:-- The only match} | 10048]] ) 10049end 10050end ) 10051it ( 'no crash with wide item and border #38840' , function () 10052exec ( [[ 10053set cot+=menuone 10054let g:list = [#{word: repeat('a', &columns - 2)}] 10055]] ) 10056feed ( 'S<C-x><C-o>' ) 10057assert_alive () 10058end ) 10059end ) 10060it ( "'pumborder' on mouse-menu displays completely within screen" , function () 10061screen : try_resize ( 40 , 12 ) 10062command ( 'set pumborder=rounded' ) 10063-- Click near right edge to test boundary handling 10064if send_mouse_grid then 10065api . nvim_input_mouse ( 'right' , 'press' , '' , 2 , 2 , 35 ) 10066else 10067feed ( '<RightMouse><35,2>' ) 10068end 10069if multigrid then 10070screen : expect ( { 10071grid =[[ 10072## grid 1 10073[2:----------------------------------------]|*11 10074[3:----------------------------------------]| 10075## grid 2 10076^ | 10077{1:~ }|*10 10078## grid 3 10079| 10080## grid 4 10081{n:╭─────────────────────╮}| 10082{n:│ Inspect │}| 10083{n:│ │}| 10084{n:│ Paste │}| 10085{n:│ Select All │}| 10086{n:│ │}| 10087{n:│ How-to disable mouse│}| 10088{n:╰─────────────────────╯}| 10089]] , 10090float_pos ={ 10091[ 4 ] ={ - 1 , 'NW' , 2 , 3 , 17 , false , 250 , 2 , 3 , 17 } , 10092} , 10093} ) 10094else 10095screen : expect ( [[ 10096^ | 10097{1:~ }|*2 10098{1:~ }{n:╭─────────────────────╮}| 10099{1:~ }{n:│ Inspect │}| 10100{1:~ }{n:│ │}| 10101{1:~ }{n:│ Paste │}| 10102{1:~ }{n:│ Select All │}| 10103{1:~ }{n:│ │}| 10104{1:~ }{n:│ How-to disable mouse│}| 10105{1:~ }{n:╰─────────────────────╯}| 10106| 10107]] ) 10108end 10109if send_mouse_grid then 10110api . nvim_input_mouse ( 'move' , '' , '' , 4 , 1 , 1 ) 10111else 10112feed ( '<MouseMove><25,4>' ) 10113end 10114if multigrid then 10115screen : expect ( { 10116grid =[[ 10117## grid 1 10118[2:----------------------------------------]|*11 10119[3:----------------------------------------]| 10120## grid 2 10121^ | 10122{1:~ }|*10 10123## grid 3 10124| 10125## grid 4 10126{n:╭─────────────────────╮}| 10127{n:│}{12: Inspect }{n:│}| 10128{n:│ │}| 10129{n:│ Paste │}| 10130{n:│ Select All │}| 10131{n:│ │}| 10132{n:│ How-to disable mouse│}| 10133{n:╰─────────────────────╯}| 10134]] , 10135float_pos ={ 10136[ 4 ] ={ - 1 , 'NW' , 2 , 3 , 17 , false , 250 , 2 , 3 , 17 } , 10137} , 10138} ) 10139else 10140screen : expect ( [[ 10141^ | 10142{1:~ }|*2 10143{1:~ }{n:╭─────────────────────╮}| 10144{1:~ }{n:│}{12: Inspect }{n:│}| 10145{1:~ }{n:│ │}| 10146{1:~ }{n:│ Paste │}| 10147{1:~ }{n:│ Select All │}| 10148{1:~ }{n:│ │}| 10149{1:~ }{n:│ How-to disable mouse│}| 10150{1:~ }{n:╰─────────────────────╯}| 10151| 10152]] ) 10153end 10154-- when right-clicking on the bottom menu, it should appear above the mouse_row 10155if send_mouse_grid then 10156api . nvim_input_mouse ( 'right' , 'press' , '' , 2 , 8 , 20 ) 10157else 10158feed ( '<RightMouse><20,8>' ) 10159end 10160if multigrid then 10161screen : expect ( { 10162grid =[[ 10163## grid 1 10164[2:----------------------------------------]|*11 10165[3:----------------------------------------]| 10166## grid 2 10167^ | 10168{1:~ }|*10 10169## grid 3 10170| 10171## grid 4 10172{n:╭─────────────────────╮}| 10173{n:│ Inspect │}| 10174{n:│ │}| 10175{n:│ Paste │}| 10176{n:│ Select All │}| 10177{n:│ │}| 10178{n:│ How-to disable mouse│}| 10179{n:╰─────────────────────╯}| 10180]] , 10181float_pos ={ 10182[ 4 ] ={ - 1 , 'SW' , 2 , 6 , 17 , false , 250 , 2 , 0 , 17 } , 10183} , 10184} ) 10185else 10186screen : expect ( [[ 10187^ {n:╭─────────────────────╮}| 10188{1:~ }{n:│ Inspect │}| 10189{1:~ }{n:│ │}| 10190{1:~ }{n:│ Paste │}| 10191{1:~ }{n:│ Select All │}| 10192{1:~ }{n:│ │}| 10193{1:~ }{n:│ How-to disable mouse│}| 10194{1:~ }{n:╰─────────────────────╯}| 10195{1:~ }|*3 10196| 10197]] ) 10198end 10199end ) 10200end 10201 10202describe ( 'with ext_multigrid and actual mouse grid' , function () 10203with_ext_multigrid ( true , true ) 10204end ) 10205 10206describe ( 'with ext_multigrid and mouse grid 0' , function () 10207with_ext_multigrid ( true , false ) 10208end ) 10209 10210describe ( 'without ext_multigrid' , function () 10211with_ext_multigrid ( false , false ) 10212end ) 10213end )