popupmenu_spec.lua 225 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949
  1. local t = require('test.testutil')
  2. local n = require('test.functional.testnvim')()
  3. local Screen = require('test.functional.ui.screen')
  4. local assert_alive = n.assert_alive
  5. local clear, feed = n.clear, n.feed
  6. local source = n.source
  7. local insert = n.insert
  8. local api = n.api
  9. local async_meths = n.async_meths
  10. local command = n.command
  11. local fn = n.fn
  12. local eq = t.eq
  13. local pcall_err = t.pcall_err
  14. local exec_lua = n.exec_lua
  15. local exec = n.exec
  16. describe('ui/ext_popupmenu', function()
  17. local screen
  18. before_each(function()
  19. clear()
  20. screen = Screen.new(60, 8, { rgb = true, ext_popupmenu = true })
  21. source([[
  22. function! TestComplete() abort
  23. call complete(1, [{'word':'foo', 'abbr':'fo', 'menu':'the foo', 'info':'foo-y', 'kind':'x'}, 'bar', 'spam'])
  24. return ''
  25. endfunction
  26. ]])
  27. end)
  28. local expected = {
  29. { 'fo', 'x', 'the foo', 'foo-y' },
  30. { 'bar', '', '', '' },
  31. { 'spam', '', '', '' },
  32. }
  33. it('works', function()
  34. feed('o<C-r>=TestComplete()<CR>')
  35. screen:expect {
  36. grid = [[
  37. |
  38. foo^ |
  39. {1:~ }|*5
  40. {5:-- INSERT --} |
  41. ]],
  42. popupmenu = {
  43. items = expected,
  44. pos = 0,
  45. anchor = { 1, 1, 0 },
  46. },
  47. }
  48. feed('<c-p>')
  49. screen:expect {
  50. grid = [[
  51. |
  52. ^ |
  53. {1:~ }|*5
  54. {5:-- INSERT --} |
  55. ]],
  56. popupmenu = {
  57. items = expected,
  58. pos = -1,
  59. anchor = { 1, 1, 0 },
  60. },
  61. }
  62. -- down moves the selection in the menu, but does not insert anything
  63. feed('<down><down>')
  64. screen:expect {
  65. grid = [[
  66. |
  67. ^ |
  68. {1:~ }|*5
  69. {5:-- INSERT --} |
  70. ]],
  71. popupmenu = {
  72. items = expected,
  73. pos = 1,
  74. anchor = { 1, 1, 0 },
  75. },
  76. }
  77. feed('<cr>')
  78. screen:expect {
  79. grid = [[
  80. |
  81. bar^ |
  82. {1:~ }|*5
  83. {5:-- INSERT --} |
  84. ]],
  85. }
  86. end)
  87. it('can be controlled by API', function()
  88. feed('o<C-r>=TestComplete()<CR>')
  89. screen:expect {
  90. grid = [[
  91. |
  92. foo^ |
  93. {1:~ }|*5
  94. {5:-- INSERT --} |
  95. ]],
  96. popupmenu = {
  97. items = expected,
  98. pos = 0,
  99. anchor = { 1, 1, 0 },
  100. },
  101. }
  102. api.nvim_select_popupmenu_item(1, false, false, {})
  103. screen:expect {
  104. grid = [[
  105. |
  106. foo^ |
  107. {1:~ }|*5
  108. {5:-- INSERT --} |
  109. ]],
  110. popupmenu = {
  111. items = expected,
  112. pos = 1,
  113. anchor = { 1, 1, 0 },
  114. },
  115. }
  116. api.nvim_select_popupmenu_item(2, true, false, {})
  117. screen:expect {
  118. grid = [[
  119. |
  120. spam^ |
  121. {1:~ }|*5
  122. {5:-- INSERT --} |
  123. ]],
  124. popupmenu = {
  125. items = expected,
  126. pos = 2,
  127. anchor = { 1, 1, 0 },
  128. },
  129. }
  130. api.nvim_select_popupmenu_item(0, true, true, {})
  131. screen:expect([[
  132. |
  133. foo^ |
  134. {1:~ }|*5
  135. {5:-- INSERT --} |
  136. ]])
  137. feed('<c-w><C-r>=TestComplete()<CR>')
  138. screen:expect {
  139. grid = [[
  140. |
  141. foo^ |
  142. {1:~ }|*5
  143. {5:-- INSERT --} |
  144. ]],
  145. popupmenu = {
  146. items = expected,
  147. pos = 0,
  148. anchor = { 1, 1, 0 },
  149. },
  150. }
  151. api.nvim_select_popupmenu_item(-1, false, false, {})
  152. screen:expect {
  153. grid = [[
  154. |
  155. foo^ |
  156. {1:~ }|*5
  157. {5:-- INSERT --} |
  158. ]],
  159. popupmenu = {
  160. items = expected,
  161. pos = -1,
  162. anchor = { 1, 1, 0 },
  163. },
  164. }
  165. api.nvim_select_popupmenu_item(1, true, false, {})
  166. screen:expect {
  167. grid = [[
  168. |
  169. bar^ |
  170. {1:~ }|*5
  171. {5:-- INSERT --} |
  172. ]],
  173. popupmenu = {
  174. items = expected,
  175. pos = 1,
  176. anchor = { 1, 1, 0 },
  177. },
  178. }
  179. api.nvim_select_popupmenu_item(-1, true, false, {})
  180. screen:expect {
  181. grid = [[
  182. |
  183. ^ |
  184. {1:~ }|*5
  185. {5:-- INSERT --} |
  186. ]],
  187. popupmenu = {
  188. items = expected,
  189. pos = -1,
  190. anchor = { 1, 1, 0 },
  191. },
  192. }
  193. api.nvim_select_popupmenu_item(0, true, false, {})
  194. screen:expect {
  195. grid = [[
  196. |
  197. foo^ |
  198. {1:~ }|*5
  199. {5:-- INSERT --} |
  200. ]],
  201. popupmenu = {
  202. items = expected,
  203. pos = 0,
  204. anchor = { 1, 1, 0 },
  205. },
  206. }
  207. api.nvim_select_popupmenu_item(-1, true, true, {})
  208. screen:expect([[
  209. |
  210. ^ |
  211. {1:~ }|*5
  212. {5:-- INSERT --} |
  213. ]])
  214. command('set wildmenu')
  215. command('set wildoptions=pum')
  216. local expected_wildpum = {
  217. { 'define', '', '', '' },
  218. { 'jump', '', '', '' },
  219. { 'list', '', '', '' },
  220. { 'place', '', '', '' },
  221. { 'undefine', '', '', '' },
  222. { 'unplace', '', '', '' },
  223. }
  224. feed('<Esc>:sign <Tab>')
  225. screen:expect({
  226. grid = [[
  227. |*2
  228. {1:~ }|*5
  229. :sign define^ |
  230. ]],
  231. popupmenu = {
  232. items = expected_wildpum,
  233. pos = 0,
  234. anchor = { 1, 7, 6 },
  235. },
  236. })
  237. api.nvim_select_popupmenu_item(-1, true, false, {})
  238. screen:expect({
  239. grid = [[
  240. |*2
  241. {1:~ }|*5
  242. :sign ^ |
  243. ]],
  244. popupmenu = {
  245. items = expected_wildpum,
  246. pos = -1,
  247. anchor = { 1, 7, 6 },
  248. },
  249. })
  250. api.nvim_select_popupmenu_item(5, true, false, {})
  251. screen:expect({
  252. grid = [[
  253. |*2
  254. {1:~ }|*5
  255. :sign unplace^ |
  256. ]],
  257. popupmenu = {
  258. items = expected_wildpum,
  259. pos = 5,
  260. anchor = { 1, 7, 6 },
  261. },
  262. })
  263. api.nvim_select_popupmenu_item(-1, true, true, {})
  264. screen:expect({
  265. grid = [[
  266. |*2
  267. {1:~ }|*5
  268. :sign ^ |
  269. ]],
  270. })
  271. feed('<Tab>')
  272. screen:expect({
  273. grid = [[
  274. |*2
  275. {1:~ }|*5
  276. :sign define^ |
  277. ]],
  278. popupmenu = {
  279. items = expected_wildpum,
  280. pos = 0,
  281. anchor = { 1, 7, 6 },
  282. },
  283. })
  284. api.nvim_select_popupmenu_item(5, true, true, {})
  285. screen:expect({
  286. grid = [[
  287. |*2
  288. {1:~ }|*5
  289. :sign unplace^ |
  290. ]],
  291. })
  292. local function test_pum_select_mappings()
  293. screen:set_option('ext_popupmenu', true)
  294. feed('<Esc>A<C-r>=TestComplete()<CR>')
  295. screen:expect {
  296. grid = [[
  297. |
  298. foo^ |
  299. {1:~ }|*5
  300. {5:-- INSERT --} |
  301. ]],
  302. popupmenu = {
  303. items = expected,
  304. pos = 0,
  305. anchor = { 1, 1, 0 },
  306. },
  307. }
  308. feed('<f1>')
  309. screen:expect {
  310. grid = [[
  311. |
  312. spam^ |
  313. {1:~ }|*5
  314. {5:-- INSERT --} |
  315. ]],
  316. popupmenu = {
  317. items = expected,
  318. pos = 2,
  319. anchor = { 1, 1, 0 },
  320. },
  321. }
  322. feed('<f2>')
  323. screen:expect {
  324. grid = [[
  325. |
  326. spam^ |
  327. {1:~ }|*5
  328. {5:-- INSERT --} |
  329. ]],
  330. popupmenu = {
  331. items = expected,
  332. pos = -1,
  333. anchor = { 1, 1, 0 },
  334. },
  335. }
  336. feed('<f3>')
  337. screen:expect([[
  338. |
  339. bar^ |
  340. {1:~ }|*5
  341. {5:-- INSERT --} |
  342. ]])
  343. feed('<Esc>:sign <Tab>')
  344. screen:expect({
  345. grid = [[
  346. |
  347. bar |
  348. {1:~ }|*5
  349. :sign define^ |
  350. ]],
  351. popupmenu = {
  352. items = expected_wildpum,
  353. pos = 0,
  354. anchor = { 1, 7, 6 },
  355. },
  356. })
  357. feed('<f1>')
  358. screen:expect({
  359. grid = [[
  360. |
  361. bar |
  362. {1:~ }|*5
  363. :sign list^ |
  364. ]],
  365. popupmenu = {
  366. items = expected_wildpum,
  367. pos = 2,
  368. anchor = { 1, 7, 6 },
  369. },
  370. })
  371. feed('<f2>')
  372. screen:expect({
  373. grid = [[
  374. |
  375. bar |
  376. {1:~ }|*5
  377. :sign ^ |
  378. ]],
  379. popupmenu = {
  380. items = expected_wildpum,
  381. pos = -1,
  382. anchor = { 1, 7, 6 },
  383. },
  384. })
  385. feed('<f3>')
  386. screen:expect({
  387. grid = [[
  388. |
  389. bar |
  390. {1:~ }|*5
  391. :sign jump^ |
  392. ]],
  393. })
  394. -- also should work for builtin popupmenu
  395. screen:set_option('ext_popupmenu', false)
  396. feed('<Esc>A<C-r>=TestComplete()<CR>')
  397. screen:expect([[
  398. |
  399. foo^ |
  400. {12:fo x the foo }{1: }|
  401. {4:bar }{1: }|
  402. {4:spam }{1: }|
  403. {1:~ }|*2
  404. {5:-- INSERT --} |
  405. ]])
  406. feed('<f1>')
  407. screen:expect([[
  408. |
  409. spam^ |
  410. {4:fo x the foo }{1: }|
  411. {4:bar }{1: }|
  412. {12:spam }{1: }|
  413. {1:~ }|*2
  414. {5:-- INSERT --} |
  415. ]])
  416. feed('<f2>')
  417. screen:expect([[
  418. |
  419. spam^ |
  420. {4:fo x the foo }{1: }|
  421. {4:bar }{1: }|
  422. {4:spam }{1: }|
  423. {1:~ }|*2
  424. {5:-- INSERT --} |
  425. ]])
  426. feed('<f3>')
  427. screen:expect([[
  428. |
  429. bar^ |
  430. {1:~ }|*5
  431. {5:-- INSERT --} |
  432. ]])
  433. feed('<Esc>:sign <Tab>')
  434. screen:expect([[
  435. |
  436. bar {12: define } |
  437. {1:~ }{4: jump }{1: }|
  438. {1:~ }{4: list }{1: }|
  439. {1:~ }{4: place }{1: }|
  440. {1:~ }{4: undefine }{1: }|
  441. {1:~ }{4: unplace }{1: }|
  442. :sign define^ |
  443. ]])
  444. feed('<f1>')
  445. screen:expect([[
  446. |
  447. bar {4: define } |
  448. {1:~ }{4: jump }{1: }|
  449. {1:~ }{12: list }{1: }|
  450. {1:~ }{4: place }{1: }|
  451. {1:~ }{4: undefine }{1: }|
  452. {1:~ }{4: unplace }{1: }|
  453. :sign list^ |
  454. ]])
  455. feed('<f2>')
  456. screen:expect([[
  457. |
  458. bar {4: define } |
  459. {1:~ }{4: jump }{1: }|
  460. {1:~ }{4: list }{1: }|
  461. {1:~ }{4: place }{1: }|
  462. {1:~ }{4: undefine }{1: }|
  463. {1:~ }{4: unplace }{1: }|
  464. :sign ^ |
  465. ]])
  466. feed('<f3>')
  467. screen:expect([[
  468. |
  469. bar |
  470. {1:~ }|*5
  471. :sign jump^ |
  472. ]])
  473. end
  474. command('map! <f1> <cmd>call nvim_select_popupmenu_item(2,v:true,v:false,{})<cr>')
  475. command('map! <f2> <cmd>call nvim_select_popupmenu_item(-1,v:false,v:false,{})<cr>')
  476. command('map! <f3> <cmd>call nvim_select_popupmenu_item(1,v:false,v:true,{})<cr>')
  477. test_pum_select_mappings()
  478. command('unmap! <f1>')
  479. command('unmap! <f2>')
  480. command('unmap! <f3>')
  481. exec_lua([[
  482. vim.keymap.set('!', '<f1>', function() vim.api.nvim_select_popupmenu_item(2, true, false, {}) end)
  483. vim.keymap.set('!', '<f2>', function() vim.api.nvim_select_popupmenu_item(-1, false, false, {}) end)
  484. vim.keymap.set('!', '<f3>', function() vim.api.nvim_select_popupmenu_item(1, false, true, {}) end)
  485. ]])
  486. test_pum_select_mappings()
  487. feed('<esc>ddiaa bb cc<cr>')
  488. feed('<c-x><c-n>')
  489. screen:expect([[
  490. aa bb cc |
  491. aa^ |
  492. {12:aa }{1: }|
  493. {4:bb }{1: }|
  494. {4:cc }{1: }|
  495. {1:~ }|*2
  496. {5:-- Keyword Local completion (^N^P) }{6:match 1 of 3} |
  497. ]])
  498. feed('<f1>')
  499. screen:expect([[
  500. aa bb cc |
  501. cc^ |
  502. {4:aa }{1: }|
  503. {4:bb }{1: }|
  504. {12:cc }{1: }|
  505. {1:~ }|*2
  506. {5:-- Keyword Local completion (^N^P) }{6:match 3 of 3} |
  507. ]])
  508. feed('<f2>')
  509. screen:expect([[
  510. aa bb cc |
  511. cc^ |
  512. {4:aa }{1: }|
  513. {4:bb }{1: }|
  514. {4:cc }{1: }|
  515. {1:~ }|*2
  516. {5:-- Keyword Local completion (^N^P) }{19:Back at original} |
  517. ]])
  518. feed('<f3>')
  519. screen:expect([[
  520. aa bb cc |
  521. bb^ |
  522. {1:~ }|*5
  523. {5:-- INSERT --} |
  524. ]])
  525. end)
  526. local function source_complete_month()
  527. source([[
  528. function! TestCompleteMonth() abort
  529. call complete(1, ['January', 'February', 'March', 'April',
  530. \ 'May', 'June', 'July', 'August',
  531. \ 'September', 'October', 'November', 'December'])
  532. return ''
  533. endfunction
  534. ]])
  535. end
  536. describe('pum_set_height', function()
  537. it('can set pum height', function()
  538. source_complete_month()
  539. local month_expected = {
  540. { 'January', '', '', '' },
  541. { 'February', '', '', '' },
  542. { 'March', '', '', '' },
  543. { 'April', '', '', '' },
  544. { 'May', '', '', '' },
  545. { 'June', '', '', '' },
  546. { 'July', '', '', '' },
  547. { 'August', '', '', '' },
  548. { 'September', '', '', '' },
  549. { 'October', '', '', '' },
  550. { 'November', '', '', '' },
  551. { 'December', '', '', '' },
  552. }
  553. local pum_height = 6
  554. feed('o<C-r>=TestCompleteMonth()<CR>')
  555. api.nvim_ui_pum_set_height(pum_height)
  556. feed('<PageDown>')
  557. -- pos becomes pum_height-2 because it is subtracting 2 to keep some
  558. -- context in ins_compl_key2count()
  559. screen:expect {
  560. grid = [[
  561. |
  562. January^ |
  563. {1:~ }|*5
  564. {5:-- INSERT --} |
  565. ]],
  566. popupmenu = {
  567. items = month_expected,
  568. pos = pum_height - 2,
  569. anchor = { 1, 1, 0 },
  570. },
  571. }
  572. end)
  573. it('an error occurs if set 0 or less', function()
  574. api.nvim_ui_pum_set_height(1)
  575. eq('Expected pum height > 0', pcall_err(api.nvim_ui_pum_set_height, 0))
  576. end)
  577. it('an error occurs when ext_popupmenu is false', function()
  578. api.nvim_ui_pum_set_height(1)
  579. screen:set_option('ext_popupmenu', false)
  580. eq('It must support the ext_popupmenu option', pcall_err(api.nvim_ui_pum_set_height, 1))
  581. end)
  582. end)
  583. describe('pum_set_bounds', function()
  584. it('can set pum bounds', function()
  585. source_complete_month()
  586. local month_expected = {
  587. { 'January', '', '', '' },
  588. { 'February', '', '', '' },
  589. { 'March', '', '', '' },
  590. { 'April', '', '', '' },
  591. { 'May', '', '', '' },
  592. { 'June', '', '', '' },
  593. { 'July', '', '', '' },
  594. { 'August', '', '', '' },
  595. { 'September', '', '', '' },
  596. { 'October', '', '', '' },
  597. { 'November', '', '', '' },
  598. { 'December', '', '', '' },
  599. }
  600. local pum_height = 6
  601. feed('o<C-r>=TestCompleteMonth()<CR>')
  602. api.nvim_ui_pum_set_height(pum_height)
  603. -- set bounds w h r c
  604. api.nvim_ui_pum_set_bounds(10.5, 5.2, 6.3, 7.4)
  605. feed('<PageDown>')
  606. -- pos becomes pum_height-2 because it is subtracting 2 to keep some
  607. -- context in ins_compl_key2count()
  608. screen:expect {
  609. grid = [[
  610. |
  611. January^ |
  612. {1:~ }|*5
  613. {5:-- INSERT --} |
  614. ]],
  615. popupmenu = {
  616. items = month_expected,
  617. pos = pum_height - 2,
  618. anchor = { 1, 1, 0 },
  619. },
  620. }
  621. end)
  622. it('no error occurs if row or col set less than 0', function()
  623. api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
  624. api.nvim_ui_pum_set_bounds(1.0, 1.0, -1.0, 0.0)
  625. api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, -1.0)
  626. end)
  627. it('an error occurs if width or height set 0 or less', function()
  628. api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
  629. eq('Expected width > 0', pcall_err(api.nvim_ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0))
  630. eq('Expected height > 0', pcall_err(api.nvim_ui_pum_set_bounds, 1.0, -1.0, 1.0, 0.0))
  631. end)
  632. it('an error occurs when ext_popupmenu is false', function()
  633. api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
  634. screen:set_option('ext_popupmenu', false)
  635. eq(
  636. 'UI must support the ext_popupmenu option',
  637. pcall_err(api.nvim_ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5)
  638. )
  639. end)
  640. end)
  641. it('<PageUP>, <PageDown> works without ui_pum_set_height', function()
  642. source_complete_month()
  643. local month_expected = {
  644. { 'January', '', '', '' },
  645. { 'February', '', '', '' },
  646. { 'March', '', '', '' },
  647. { 'April', '', '', '' },
  648. { 'May', '', '', '' },
  649. { 'June', '', '', '' },
  650. { 'July', '', '', '' },
  651. { 'August', '', '', '' },
  652. { 'September', '', '', '' },
  653. { 'October', '', '', '' },
  654. { 'November', '', '', '' },
  655. { 'December', '', '', '' },
  656. }
  657. feed('o<C-r>=TestCompleteMonth()<CR>')
  658. feed('<PageDown>')
  659. screen:expect {
  660. grid = [[
  661. |
  662. January^ |
  663. {1:~ }|*5
  664. {5:-- INSERT --} |
  665. ]],
  666. popupmenu = {
  667. items = month_expected,
  668. pos = 3,
  669. anchor = { 1, 1, 0 },
  670. },
  671. }
  672. feed('<PageUp>')
  673. screen:expect {
  674. grid = [[
  675. |
  676. January^ |
  677. {1:~ }|*5
  678. {5:-- INSERT --} |
  679. ]],
  680. popupmenu = {
  681. items = month_expected,
  682. pos = 0,
  683. anchor = { 1, 1, 0 },
  684. },
  685. }
  686. end)
  687. it('works with wildoptions=pum', function()
  688. screen:try_resize(32, 10)
  689. command('set wildmenu')
  690. command('set wildoptions=pum')
  691. local wild_expected = {
  692. { 'define', '', '', '' },
  693. { 'jump', '', '', '' },
  694. { 'list', '', '', '' },
  695. { 'place', '', '', '' },
  696. { 'undefine', '', '', '' },
  697. { 'unplace', '', '', '' },
  698. }
  699. feed(':sign ')
  700. screen:expect([[
  701. |
  702. {1:~ }|*8
  703. :sign ^ |
  704. ]])
  705. eq(0, fn.wildmenumode())
  706. feed('<tab>')
  707. screen:expect {
  708. grid = [[
  709. |
  710. {1:~ }|*8
  711. :sign define^ |
  712. ]],
  713. popupmenu = { items = wild_expected, pos = 0, anchor = { 1, 9, 6 } },
  714. }
  715. eq(1, fn.wildmenumode())
  716. feed('<left>')
  717. screen:expect {
  718. grid = [[
  719. |
  720. {1:~ }|*8
  721. :sign ^ |
  722. ]],
  723. popupmenu = { items = wild_expected, pos = -1, anchor = { 1, 9, 6 } },
  724. }
  725. feed('<left>')
  726. screen:expect {
  727. grid = [[
  728. |
  729. {1:~ }|*8
  730. :sign unplace^ |
  731. ]],
  732. popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } },
  733. }
  734. feed('x')
  735. screen:expect([[
  736. |
  737. {1:~ }|*8
  738. :sign unplacex^ |
  739. ]])
  740. feed('<esc>')
  741. -- #10042: make sure shift-tab also triggers the pum
  742. feed(':sign <S-tab>')
  743. screen:expect {
  744. grid = [[
  745. |
  746. {1:~ }|*8
  747. :sign unplace^ |
  748. ]],
  749. popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } },
  750. }
  751. feed('<esc>')
  752. eq(0, fn.wildmenumode())
  753. -- check positioning with multibyte char in pattern
  754. command('e långfile1')
  755. command('sp långfile2')
  756. feed(':b lå<tab>')
  757. screen:expect {
  758. grid = [[
  759. |
  760. {1:~ }|*3
  761. {3:långfile2 }|
  762. |
  763. {1:~ }|*2
  764. {2:långfile1 }|
  765. :b långfile1^ |
  766. ]],
  767. popupmenu = {
  768. anchor = { 1, 9, 3 },
  769. items = { { 'långfile1', '', '', '' }, { 'långfile2', '', '', '' } },
  770. pos = 0,
  771. },
  772. }
  773. end)
  774. it('does not interfere with mousemodel=popup', function()
  775. exec([[
  776. set mouse=a mousemodel=popup
  777. aunmenu PopUp
  778. " Delete the default MenuPopup event handler.
  779. autocmd! nvim.popupmenu
  780. menu PopUp.foo :let g:menustr = 'foo'<CR>
  781. menu PopUp.bar :let g:menustr = 'bar'<CR>
  782. menu PopUp.baz :let g:menustr = 'baz'<CR>
  783. ]])
  784. feed('o<C-r>=TestComplete()<CR>')
  785. screen:expect {
  786. grid = [[
  787. |
  788. foo^ |
  789. {1:~ }|*5
  790. {5:-- INSERT --} |
  791. ]],
  792. popupmenu = {
  793. items = expected,
  794. pos = 0,
  795. anchor = { 1, 1, 0 },
  796. },
  797. }
  798. feed('<c-p>')
  799. screen:expect {
  800. grid = [[
  801. |
  802. ^ |
  803. {1:~ }|*5
  804. {5:-- INSERT --} |
  805. ]],
  806. popupmenu = {
  807. items = expected,
  808. pos = -1,
  809. anchor = { 1, 1, 0 },
  810. },
  811. }
  812. feed('<esc>')
  813. screen:expect {
  814. grid = [[
  815. |
  816. ^ |
  817. {1:~ }|*5
  818. |
  819. ]],
  820. }
  821. feed('<RightMouse><0,0>')
  822. screen:expect([[
  823. |
  824. {4:^foo } |
  825. {4:bar }{1: }|
  826. {4:baz }{1: }|
  827. {1:~ }|*3
  828. |
  829. ]])
  830. feed('<esc>')
  831. screen:expect([[
  832. |
  833. ^ |
  834. {1:~ }|*5
  835. |
  836. ]])
  837. end)
  838. end)
  839. describe("builtin popupmenu 'pumblend'", function()
  840. before_each(clear)
  841. it('RGB-color', function()
  842. local screen = Screen.new(60, 14)
  843. screen:set_default_attr_ids({
  844. [1] = { background = Screen.colors.Yellow },
  845. [2] = { bold = true, reverse = true },
  846. [3] = { bold = true, foreground = Screen.colors.Brown },
  847. [4] = { foreground = Screen.colors.Blue1 },
  848. [5] = { reverse = true },
  849. [6] = { background = Screen.colors.Gray55, foreground = Screen.colors.Grey45 },
  850. [7] = { background = Screen.colors.Gray55, foreground = Screen.colors.Grey0 },
  851. [8] = { background = tonumber('0x191919'), foreground = Screen.colors.Grey0 },
  852. [9] = { background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8e5') },
  853. [10] = { background = tonumber('0xffc1ff'), foreground = Screen.colors.Grey0 },
  854. [11] = { foreground = tonumber('0xffc1ff'), background = tonumber('0xe5a8e5'), bold = true },
  855. [12] = { foreground = Screen.colors.Grey55, background = Screen.colors.Gray45, bold = true },
  856. [13] = { background = tonumber('0xffc1e5'), foreground = Screen.colors.Grey0 },
  857. [14] = { background = tonumber('0xffc1e5'), foreground = tonumber('0xe5a8e5') },
  858. [15] = { background = tonumber('0xffc1ff'), foreground = tonumber('0x080202') },
  859. [16] = { background = tonumber('0xffc1ff'), bold = true, foreground = tonumber('0xf6ace9') },
  860. [17] = { background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8ff') },
  861. [18] = { background = tonumber('0xe5a8e5'), foreground = tonumber('0xffc1ff') },
  862. [19] = { background = Screen.colors.Gray45, foreground = Screen.colors.Grey55 },
  863. [20] = { bold = true },
  864. [21] = { bold = true, foreground = Screen.colors.SeaGreen4 },
  865. [22] = { background = Screen.colors.WebGray },
  866. [23] = { background = Screen.colors.Grey0 },
  867. [24] = { background = Screen.colors.LightMagenta },
  868. [25] = { background = Screen.colors.Gray75, foreground = Screen.colors.Grey25 },
  869. [26] = { background = Screen.colors.Gray75, foreground = Screen.colors.Grey0 },
  870. [27] = { background = Screen.colors.Gray50, foreground = Screen.colors.Grey0 },
  871. [28] = { background = tonumber('0xffddff'), foreground = tonumber('0x7f5d7f') },
  872. [29] = { background = tonumber('0xffddff'), foreground = Screen.colors.Grey0 },
  873. [30] = { foreground = tonumber('0xffddff'), background = tonumber('0x7f5d7f'), bold = true },
  874. [31] = { foreground = tonumber('0xffddff'), background = Screen.colors.Grey0, bold = true },
  875. [32] = { foreground = Screen.colors.Gray75, background = Screen.colors.Grey25, bold = true },
  876. [33] = { background = tonumber('0xffdd7f'), foreground = Screen.colors.Grey0 },
  877. [34] = { background = tonumber('0xffdd7f'), foreground = tonumber('0x7f5d7f') },
  878. [35] = { background = tonumber('0xffddff'), bold = true, foreground = tonumber('0x290a0a') },
  879. [36] = { background = tonumber('0xffddff'), bold = true, foreground = tonumber('0xd27294') },
  880. [37] = { background = tonumber('0xffddff'), foreground = tonumber('0x7f5dff') },
  881. [38] = { background = tonumber('0x7f5d7f'), foreground = tonumber('0xffddff') },
  882. [39] = { background = Screen.colors.Grey0, foreground = tonumber('0xffddff') },
  883. [40] = { background = Screen.colors.Gray25, foreground = Screen.colors.Grey75 },
  884. [41] = { background = tonumber('0xffddff'), foreground = tonumber('0x00003f') },
  885. [42] = { foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5') },
  886. [43] = { background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f') },
  887. [44] = { foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f') },
  888. [45] = { background = Screen.colors.WebGray, blend = 0 },
  889. })
  890. command('syntax on')
  891. command('set mouse=a')
  892. command('set pumblend=10')
  893. insert([[
  894. Lorem ipsum dolor sit amet, consectetur
  895. adipisicing elit, sed do eiusmod tempor
  896. incididunt ut labore et dolore magna aliqua.
  897. Ut enim ad minim veniam, quis nostrud
  898. exercitation ullamco laboris nisi ut aliquip ex
  899. ea commodo consequat. Duis aute irure dolor in
  900. reprehenderit in voluptate velit esse cillum
  901. dolore eu fugiat nulla pariatur. Excepteur sint
  902. occaecat cupidatat non proident, sunt in culpa
  903. qui officia deserunt mollit anim id est
  904. laborum.]])
  905. command('match Statement /el/')
  906. command('2match Comment /ut/')
  907. command('1')
  908. command('split')
  909. command('/ol')
  910. screen:expect([[
  911. Lorem ipsum d{1:ol}or sit amet, consectetur |
  912. adipisicing elit, sed do eiusmod tempor |
  913. ^incididunt ut labore et d{1:ol}ore magna aliqua. |
  914. Ut enim ad minim veniam, quis nostrud |
  915. exercitation ullamco laboris nisi ut aliquip ex |
  916. ea commodo consequat. Duis aute irure d{1:ol}or in |
  917. {2:[No Name] [+] }|
  918. Lorem ipsum d{1:ol}or sit amet, consectetur |
  919. adipisicing {3:el}it, sed do eiusmod tempor |
  920. incididunt {4:ut} labore et d{1:ol}ore magna aliqua. |
  921. Ut enim ad minim veniam, quis nostrud |
  922. exercitation ullamco laboris nisi {4:ut} aliquip ex |
  923. {5:[No Name] [+] }|
  924. |
  925. ]])
  926. feed('Obla bla <c-x><c-n>')
  927. screen:expect([[
  928. Lorem ipsum d{1:ol}or sit amet, consectetur |
  929. adipisicing elit, sed do eiusmod tempor |
  930. bla bla incididunt^ |
  931. incidid{6:u}{7:incididunt}{6:re et}{8: }d{1:ol}ore magna aliqua. |
  932. Ut enim{9: }{10:ut}{9: minim veniam}{6:,} quis nostrud |
  933. exercit{9:a}{10:labore}{9:llamco la}{6:b}oris nisi ut aliquip ex |
  934. {2:[No Nam}{11:e}{42:et}{11:[+] }{12: }{2: }|
  935. Lorem i{9:p}{10:dolor}{13:e}{14:l}{9:or sit a}{6:m}et, consectetur |
  936. adipisi{9:c}{10:magn}{15:a}{16:l}{9:it, sed d}{6:o} eiusmod tempor |
  937. bla bla{9: }{10:aliqua}{9:dunt }{6: } |
  938. incidid{9:u}{10:Ut}{9: }{17:ut}{9: labore et}{6: }d{1:ol}ore magna aliqua. |
  939. Ut enim{9: }{10:enim}{9:inim veniam}{6:,} quis nostrud |
  940. {5:[No Nam}{18:e}{42:ad}{18:[+] }{19: }{5: }|
  941. {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
  942. ]])
  943. command('set pumblend=0')
  944. screen:expect([[
  945. Lorem ipsum d{1:ol}or sit amet, consectetur |
  946. adipisicing elit, sed do eiusmod tempor |
  947. bla bla incididunt^ |
  948. incidid{22: incididunt }{23: }d{1:ol}ore magna aliqua. |
  949. Ut enim{24: ut }{22: } quis nostrud |
  950. exercit{24: labore }{22: }oris nisi ut aliquip ex |
  951. {2:[No Nam}{24: et }{22: }{2: }|
  952. Lorem i{24: dolore }{22: }et, consectetur |
  953. adipisi{24: magna }{22: } eiusmod tempor |
  954. bla bla{24: aliqua }{22: } |
  955. incidid{24: Ut }{22: }d{1:ol}ore magna aliqua. |
  956. Ut enim{24: enim }{22: } quis nostrud |
  957. {5:[No Nam}{24: ad }{22: }{5: }|
  958. {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
  959. ]])
  960. command('set pumblend=50')
  961. screen:expect([[
  962. Lorem ipsum d{1:ol}or sit amet, consectetur |
  963. adipisicing elit, sed do eiusmod tempor |
  964. bla bla incididunt^ |
  965. incidid{25:u}{26:incididunt}{25:re et}{27: }d{1:ol}ore magna aliqua. |
  966. Ut enim{28: }{29:ut}{28: minim veniam}{25:,} quis nostrud |
  967. exercit{28:a}{29:labore}{28:llamco la}{25:b}oris nisi ut aliquip ex |
  968. {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }|
  969. Lorem i{28:p}{29:dolor}{33:e}{34:l}{28:or sit a}{25:m}et, consectetur |
  970. adipisi{28:c}{29:magn}{35:a}{36:l}{28:it, sed d}{25:o} eiusmod tempor |
  971. bla bla{28: }{29:aliqua}{28:dunt }{25: } |
  972. incidid{28:u}{29:Ut}{28: }{37:ut}{28: labore et}{25: }d{1:ol}ore magna aliqua. |
  973. Ut enim{28: }{29:enim}{28:inim veniam}{25:,} quis nostrud |
  974. {5:[No Nam}{38:e}{44:ad}{38:[+] }{40: }{5: }|
  975. {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
  976. ]])
  977. api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
  978. screen:expect([[
  979. Lorem ipsum d{1:ol}or sit amet, consectetur |
  980. adipisicing elit, sed do eiusmod tempor |
  981. bla bla incididunt^ |
  982. incidid{25:u}{26:incididunt}{25:re et}{27: }d{1:ol}ore magna aliqua. |
  983. Ut enim{28: }{29:ut}{28: minim veniam}{25:,} quis nostrud |
  984. exercit{28:a}{29:labore}{28:llamco la}{25:b}oris nisi ut aliquip ex |
  985. {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }|
  986. incidid{28:u}{29:dol}{41:or}{29:e}{28:labore et}{25: }d{1:ol}ore magna aliqua. |
  987. Ut enim{28: }{29:magna}{28:nim veniam}{25:,} quis nostrud |
  988. exercit{28:a}{29:aliqua}{28:llamco la}{25:b}oris nisi {4:ut} aliquip ex |
  989. ea comm{28:o}{29:Ut}{28: consequat. D}{25:u}is a{4:ut}e irure d{1:ol}or in |
  990. reprehe{28:n}{29:enim}{28:t in v}{34:ol}{28:upt}{25:a}te v{3:el}it esse cillum |
  991. {5:[No Nam}{38:e}{44:ad}{38:[+] }{40: }{5: }|
  992. {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
  993. ]])
  994. -- can disable blending for individual attribute. For instance current
  995. -- selected item. (also tests that `hi Pmenu*` take immediate effect)
  996. command('hi PMenuSel blend=0')
  997. screen:expect([[
  998. Lorem ipsum d{1:ol}or sit amet, consectetur |
  999. adipisicing elit, sed do eiusmod tempor |
  1000. bla bla incididunt^ |
  1001. incidid{45: incididunt }{27: }d{1:ol}ore magna aliqua. |
  1002. Ut enim{28: }{29:ut}{28: minim veniam}{25:,} quis nostrud |
  1003. exercit{28:a}{29:labore}{28:llamco la}{25:b}oris nisi ut aliquip ex |
  1004. {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }|
  1005. incidid{28:u}{29:dol}{41:or}{29:e}{28:labore et}{25: }d{1:ol}ore magna aliqua. |
  1006. Ut enim{28: }{29:magna}{28:nim veniam}{25:,} quis nostrud |
  1007. exercit{28:a}{29:aliqua}{28:llamco la}{25:b}oris nisi {4:ut} aliquip ex |
  1008. ea comm{28:o}{29:Ut}{28: consequat. D}{25:u}is a{4:ut}e irure d{1:ol}or in |
  1009. reprehe{28:n}{29:enim}{28:t in v}{34:ol}{28:upt}{25:a}te v{3:el}it esse cillum |
  1010. {5:[No Nam}{38:e}{44:ad}{38:[+] }{40: }{5: }|
  1011. {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
  1012. ]])
  1013. feed('<c-e>')
  1014. screen:expect([[
  1015. Lorem ipsum d{1:ol}or sit amet, consectetur |
  1016. adipisicing elit, sed do eiusmod tempor |
  1017. bla bla ^ |
  1018. incididunt ut labore et d{1:ol}ore magna aliqua. |
  1019. Ut enim ad minim veniam, quis nostrud |
  1020. exercitation ullamco laboris nisi ut aliquip ex |
  1021. {2:[No Name] [+] }|
  1022. incididunt {4:ut} labore et d{1:ol}ore magna aliqua. |
  1023. Ut enim ad minim veniam, quis nostrud |
  1024. exercitation ullamco laboris nisi {4:ut} aliquip ex |
  1025. ea commodo consequat. Duis a{4:ut}e irure d{1:ol}or in |
  1026. reprehenderit in v{1:ol}uptate v{3:el}it esse cillum |
  1027. {5:[No Name] [+] }|
  1028. {20:-- INSERT --} |
  1029. ]])
  1030. end)
  1031. it('256-color (non-RGB)', function()
  1032. local screen = Screen.new(60, 8, { rgb = false })
  1033. screen:set_default_attr_ids({
  1034. [1] = { foreground = Screen.colors.Grey0, background = tonumber('0x000007') },
  1035. [2] = { foreground = tonumber('0x000055'), background = tonumber('0x000007') },
  1036. [3] = { foreground = tonumber('0x00008f'), background = Screen.colors.Grey0 },
  1037. [4] = { foreground = Screen.colors.Grey0, background = tonumber('0x0000e1') },
  1038. [5] = { foreground = tonumber('0x0000d1'), background = tonumber('0x0000e1') },
  1039. [6] = { foreground = Screen.colors.NavyBlue, background = tonumber('0x0000f8') },
  1040. [7] = { foreground = tonumber('0x0000a5'), background = tonumber('0x0000f8') },
  1041. [8] = { foreground = tonumber('0x00000c') },
  1042. [9] = { bold = true },
  1043. [10] = { foreground = tonumber('0x000002') },
  1044. })
  1045. command('set pumblend=10')
  1046. insert([[
  1047. Lorem ipsum dolor sit amet, consectetur
  1048. adipisicing elit, sed do eiusmod tempor
  1049. incididunt ut labore et dolore magna aliqua.
  1050. Ut enim ad minim veniam, quis nostrud
  1051. laborum.]])
  1052. feed('ggOdo<c-x><c-n>')
  1053. screen:expect([[
  1054. dolor^ |
  1055. {1:dolor}{2: ipsum dol}or sit amet, consectetur |
  1056. {4:do}{5:ipisicing eli}t, sed do eiusmod tempor |
  1057. {4:dolore}{5:dunt ut l}abore et dolore magna aliqua. |
  1058. Ut enim ad minim veniam, quis nostrud |
  1059. laborum. |
  1060. {8:~ }|
  1061. {9:-- Keyword Local completion (^N^P) }{10:match 1 of 3} |
  1062. ]])
  1063. end)
  1064. end)
  1065. describe('builtin popupmenu', function()
  1066. before_each(clear)
  1067. local function with_ext_multigrid(multigrid)
  1068. local screen
  1069. before_each(function()
  1070. screen = Screen.new(32, 20, { ext_multigrid = multigrid })
  1071. screen:set_default_attr_ids({
  1072. -- popup selected item / scrollbar track
  1073. s = { background = Screen.colors.Grey },
  1074. -- popup non-selected item
  1075. n = { background = Screen.colors.Plum1 },
  1076. -- popup scrollbar knob
  1077. c = { background = Screen.colors.Black },
  1078. [1] = { bold = true, foreground = Screen.colors.Blue },
  1079. [2] = { bold = true },
  1080. [3] = { reverse = true },
  1081. [4] = { bold = true, reverse = true },
  1082. [5] = { bold = true, foreground = Screen.colors.SeaGreen },
  1083. [6] = { foreground = Screen.colors.White, background = Screen.colors.Red },
  1084. [7] = { background = Screen.colors.Yellow }, -- Search
  1085. [8] = { foreground = Screen.colors.Red },
  1086. [9] = { foreground = Screen.colors.Yellow, background = Screen.colors.Green },
  1087. [10] = { foreground = Screen.colors.White, background = Screen.colors.Green },
  1088. ks = { foreground = Screen.colors.Red, background = Screen.colors.Grey },
  1089. kn = { foreground = Screen.colors.Red, background = Screen.colors.Plum1 },
  1090. xs = { foreground = Screen.colors.Black, background = Screen.colors.Grey },
  1091. xn = { foreground = Screen.colors.White, background = Screen.colors.Plum1 },
  1092. ms = { foreground = Screen.colors.Blue, background = Screen.colors.Grey },
  1093. mn = { foreground = Screen.colors.Blue, background = Screen.colors.Plum1 },
  1094. ds = { foreground = Screen.colors.DarkRed, background = Screen.colors.Grey },
  1095. dn = { foreground = Screen.colors.DarkRed, background = Screen.colors.Plum1 },
  1096. ums = {
  1097. foreground = Screen.colors.Blue,
  1098. background = Screen.colors.Grey,
  1099. underline = true,
  1100. },
  1101. umn = {
  1102. foreground = Screen.colors.Blue,
  1103. background = Screen.colors.Plum1,
  1104. underline = true,
  1105. },
  1106. uds = {
  1107. foreground = Screen.colors.DarkRed,
  1108. background = Screen.colors.Grey,
  1109. underline = true,
  1110. },
  1111. udn = {
  1112. foreground = Screen.colors.DarkRed,
  1113. background = Screen.colors.Plum1,
  1114. underline = true,
  1115. },
  1116. })
  1117. end)
  1118. it('with preview-window above', function()
  1119. feed(':ped<CR><c-w>4+')
  1120. feed('iaa bb cc dd ee ff gg hh ii jj<cr>')
  1121. feed('<c-x><c-n>')
  1122. if multigrid then
  1123. screen:expect {
  1124. grid = [[
  1125. ## grid 1
  1126. [4:--------------------------------]|*8
  1127. {3:[No Name] [Preview][+] }|
  1128. [2:--------------------------------]|*9
  1129. {4:[No Name] [+] }|
  1130. [3:--------------------------------]|
  1131. ## grid 2
  1132. aa bb cc dd ee ff gg hh ii jj |
  1133. aa^ |
  1134. {1:~ }|*7
  1135. ## grid 3
  1136. {2:-- }{5:match 1 of 10} |
  1137. ## grid 4
  1138. aa bb cc dd ee ff gg hh ii jj |
  1139. aa |
  1140. {1:~ }|*6
  1141. ## grid 5
  1142. {s:aa }{c: }|
  1143. {n:bb }{c: }|
  1144. {n:cc }{c: }|
  1145. {n:dd }{c: }|
  1146. {n:ee }{c: }|
  1147. {n:ff }{c: }|
  1148. {n:gg }{s: }|
  1149. {n:hh }{s: }|
  1150. ]],
  1151. float_pos = {
  1152. [5] = { -1, 'NW', 2, 2, 0, false, 100 },
  1153. },
  1154. }
  1155. else
  1156. screen:expect([[
  1157. aa bb cc dd ee ff gg hh ii jj |
  1158. aa |
  1159. {1:~ }|*6
  1160. {3:[No Name] [Preview][+] }|
  1161. aa bb cc dd ee ff gg hh ii jj |
  1162. aa^ |
  1163. {s:aa }{c: }{1: }|
  1164. {n:bb }{c: }{1: }|
  1165. {n:cc }{c: }{1: }|
  1166. {n:dd }{c: }{1: }|
  1167. {n:ee }{c: }{1: }|
  1168. {n:ff }{c: }{1: }|
  1169. {n:gg }{s: }{1: }|
  1170. {n:hh }{s: }{4: }|
  1171. {2:-- }{5:match 1 of 10} |
  1172. ]])
  1173. end
  1174. end)
  1175. it('with preview-window below', function()
  1176. feed(':ped<CR><c-w>4+<c-w>r')
  1177. feed('iaa bb cc dd ee ff gg hh ii jj<cr>')
  1178. feed('<c-x><c-n>')
  1179. if multigrid then
  1180. screen:expect {
  1181. grid = [[
  1182. ## grid 1
  1183. [2:--------------------------------]|*9
  1184. {4:[No Name] [+] }|
  1185. [4:--------------------------------]|*8
  1186. {3:[No Name] [Preview][+] }|
  1187. [3:--------------------------------]|
  1188. ## grid 2
  1189. aa bb cc dd ee ff gg hh ii jj |
  1190. aa^ |
  1191. {1:~ }|*7
  1192. ## grid 3
  1193. {2:-- }{5:match 1 of 10} |
  1194. ## grid 4
  1195. aa bb cc dd ee ff gg hh ii jj |
  1196. aa |
  1197. {1:~ }|*6
  1198. ## grid 5
  1199. {s:aa }{c: }|
  1200. {n:bb }{c: }|
  1201. {n:cc }{c: }|
  1202. {n:dd }{c: }|
  1203. {n:ee }{c: }|
  1204. {n:ff }{c: }|
  1205. {n:gg }{s: }|
  1206. {n:hh }{s: }|
  1207. ]],
  1208. float_pos = {
  1209. [5] = { -1, 'NW', 2, 2, 0, false, 100 },
  1210. },
  1211. }
  1212. else
  1213. screen:expect([[
  1214. aa bb cc dd ee ff gg hh ii jj |
  1215. aa^ |
  1216. {s:aa }{c: }{1: }|
  1217. {n:bb }{c: }{1: }|
  1218. {n:cc }{c: }{1: }|
  1219. {n:dd }{c: }{1: }|
  1220. {n:ee }{c: }{1: }|
  1221. {n:ff }{c: }{1: }|
  1222. {n:gg }{s: }{1: }|
  1223. {n:hh }{s: }{4: }|
  1224. aa bb cc dd ee ff gg hh ii jj |
  1225. aa |
  1226. {1:~ }|*6
  1227. {3:[No Name] [Preview][+] }|
  1228. {2:-- }{5:match 1 of 10} |
  1229. ]])
  1230. end
  1231. end)
  1232. it('with preview-window above and tall and inverted', function()
  1233. feed(':ped<CR><c-w>8+')
  1234. feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
  1235. feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
  1236. feed('kk<cr>ll<cr>mm<cr>nn<cr>oo<cr>')
  1237. feed('<c-x><c-n>')
  1238. if multigrid then
  1239. screen:expect {
  1240. grid = [[
  1241. ## grid 1
  1242. [4:--------------------------------]|*4
  1243. {3:[No Name] [Preview][+] }|
  1244. [2:--------------------------------]|*13
  1245. {4:[No Name] [+] }|
  1246. [3:--------------------------------]|
  1247. ## grid 2
  1248. dd |
  1249. ee |
  1250. ff |
  1251. gg |
  1252. hh |
  1253. ii |
  1254. jj |
  1255. kk |
  1256. ll |
  1257. mm |
  1258. nn |
  1259. oo |
  1260. aa^ |
  1261. ## grid 3
  1262. {2:-- }{5:match 1 of 15} |
  1263. ## grid 4
  1264. aa |
  1265. bb |
  1266. cc |
  1267. dd |
  1268. ## grid 5
  1269. {s:aa }{c: }|
  1270. {n:bb }{c: }|
  1271. {n:cc }{c: }|
  1272. {n:dd }{c: }|
  1273. {n:ee }{c: }|
  1274. {n:ff }{c: }|
  1275. {n:gg }{c: }|
  1276. {n:hh }{c: }|
  1277. {n:ii }{c: }|
  1278. {n:jj }{c: }|
  1279. {n:kk }{c: }|
  1280. {n:ll }{s: }|
  1281. {n:mm }{s: }|
  1282. ]],
  1283. float_pos = {
  1284. [5] = { -1, 'SW', 2, 12, 0, false, 100 },
  1285. },
  1286. }
  1287. else
  1288. screen:expect([[
  1289. aa |
  1290. bb |
  1291. cc |
  1292. dd |
  1293. {s:aa }{c: }{3:ew][+] }|
  1294. {n:bb }{c: } |
  1295. {n:cc }{c: } |
  1296. {n:dd }{c: } |
  1297. {n:ee }{c: } |
  1298. {n:ff }{c: } |
  1299. {n:gg }{c: } |
  1300. {n:hh }{c: } |
  1301. {n:ii }{c: } |
  1302. {n:jj }{c: } |
  1303. {n:kk }{c: } |
  1304. {n:ll }{s: } |
  1305. {n:mm }{s: } |
  1306. aa^ |
  1307. {4:[No Name] [+] }|
  1308. {2:-- }{5:match 1 of 15} |
  1309. ]])
  1310. end
  1311. end)
  1312. it('with preview-window above and short and inverted', function()
  1313. feed(':ped<CR><c-w>4+')
  1314. feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
  1315. feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
  1316. feed('<c-x><c-n>')
  1317. if multigrid then
  1318. screen:expect {
  1319. grid = [[
  1320. ## grid 1
  1321. [4:--------------------------------]|*8
  1322. {3:[No Name] [Preview][+] }|
  1323. [2:--------------------------------]|*9
  1324. {4:[No Name] [+] }|
  1325. [3:--------------------------------]|
  1326. ## grid 2
  1327. cc |
  1328. dd |
  1329. ee |
  1330. ff |
  1331. gg |
  1332. hh |
  1333. ii |
  1334. jj |
  1335. aa^ |
  1336. ## grid 3
  1337. {2:-- }{5:match 1 of 10} |
  1338. ## grid 4
  1339. aa |
  1340. bb |
  1341. cc |
  1342. dd |
  1343. ee |
  1344. ff |
  1345. gg |
  1346. hh |
  1347. ## grid 5
  1348. {s:aa }{c: }|
  1349. {n:bb }{c: }|
  1350. {n:cc }{c: }|
  1351. {n:dd }{c: }|
  1352. {n:ee }{c: }|
  1353. {n:ff }{c: }|
  1354. {n:gg }{c: }|
  1355. {n:hh }{c: }|
  1356. {n:ii }{s: }|
  1357. ]],
  1358. float_pos = {
  1359. [5] = { -1, 'SW', 2, 8, 0, false, 100 },
  1360. },
  1361. }
  1362. else
  1363. screen:expect([[
  1364. aa |
  1365. bb |
  1366. cc |
  1367. dd |
  1368. ee |
  1369. ff |
  1370. gg |
  1371. hh |
  1372. {s:aa }{c: }{3:ew][+] }|
  1373. {n:bb }{c: } |
  1374. {n:cc }{c: } |
  1375. {n:dd }{c: } |
  1376. {n:ee }{c: } |
  1377. {n:ff }{c: } |
  1378. {n:gg }{c: } |
  1379. {n:hh }{c: } |
  1380. {n:ii }{s: } |
  1381. aa^ |
  1382. {4:[No Name] [+] }|
  1383. {2:-- }{5:match 1 of 10} |
  1384. ]])
  1385. end
  1386. end)
  1387. it('with preview-window below and inverted', function()
  1388. feed(':ped<CR><c-w>4+<c-w>r')
  1389. feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
  1390. feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
  1391. feed('<c-x><c-n>')
  1392. if multigrid then
  1393. screen:expect {
  1394. grid = [[
  1395. ## grid 1
  1396. [2:--------------------------------]|*9
  1397. {4:[No Name] [+] }|
  1398. [4:--------------------------------]|*8
  1399. {3:[No Name] [Preview][+] }|
  1400. [3:--------------------------------]|
  1401. ## grid 2
  1402. cc |
  1403. dd |
  1404. ee |
  1405. ff |
  1406. gg |
  1407. hh |
  1408. ii |
  1409. jj |
  1410. aa^ |
  1411. ## grid 3
  1412. {2:-- }{5:match 1 of 10} |
  1413. ## grid 4
  1414. aa |
  1415. bb |
  1416. cc |
  1417. dd |
  1418. ee |
  1419. ff |
  1420. gg |
  1421. hh |
  1422. ## grid 5
  1423. {s:aa }{c: }|
  1424. {n:bb }{c: }|
  1425. {n:cc }{c: }|
  1426. {n:dd }{c: }|
  1427. {n:ee }{c: }|
  1428. {n:ff }{c: }|
  1429. {n:gg }{s: }|
  1430. {n:hh }{s: }|
  1431. ]],
  1432. float_pos = {
  1433. [5] = { -1, 'SW', 2, 8, 0, false, 100 },
  1434. },
  1435. }
  1436. else
  1437. screen:expect([[
  1438. {s:aa }{c: } |
  1439. {n:bb }{c: } |
  1440. {n:cc }{c: } |
  1441. {n:dd }{c: } |
  1442. {n:ee }{c: } |
  1443. {n:ff }{c: } |
  1444. {n:gg }{s: } |
  1445. {n:hh }{s: } |
  1446. aa^ |
  1447. {4:[No Name] [+] }|
  1448. aa |
  1449. bb |
  1450. cc |
  1451. dd |
  1452. ee |
  1453. ff |
  1454. gg |
  1455. hh |
  1456. {3:[No Name] [Preview][+] }|
  1457. {2:-- }{5:match 1 of 10} |
  1458. ]])
  1459. end
  1460. end)
  1461. if not multigrid then
  1462. describe('popup and preview window do not overlap', function()
  1463. before_each(function()
  1464. screen:try_resize(53, 20)
  1465. end)
  1466. -- oldtest: Test_popup_and_previewwindow_dump_pedit()
  1467. it('with :pedit', function()
  1468. exec([[
  1469. set previewheight=9
  1470. silent! pedit
  1471. call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
  1472. exec "norm! G\<C-E>\<C-E>"
  1473. ]])
  1474. feed('o')
  1475. n.poke_eventloop()
  1476. feed('<C-X><C-N>')
  1477. screen:expect([[
  1478. ab0 |
  1479. ab1 |
  1480. ab2 |
  1481. ab3 |
  1482. ab4 |
  1483. ab5 |
  1484. ab6 |
  1485. ab7 |
  1486. ab8 |
  1487. {s:ab0 }{c: }{3:ew][+] }|
  1488. {n:ab1 }{c: } |
  1489. {n:ab2 }{c: } |
  1490. {n:ab3 }{c: } |
  1491. {n:ab4 }{s: } |
  1492. {n:ab5 }{s: } |
  1493. {n:ab6 }{s: } |
  1494. ab0^ |
  1495. {1:~ }|
  1496. {4:[No Name] [+] }|
  1497. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 10} |
  1498. ]])
  1499. end)
  1500. -- oldtest: Test_popup_and_previewwindow_dump_pbuffer()
  1501. it('with :pbuffer', function()
  1502. exec([[
  1503. set previewheight=9
  1504. silent! pbuffer
  1505. call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
  1506. exec "norm! G\<C-E>\<C-E>\<C-E>"
  1507. ]])
  1508. feed('o')
  1509. n.poke_eventloop()
  1510. feed('<C-X><C-N>')
  1511. screen:expect([[
  1512. ab0 |
  1513. ab1 |
  1514. ab2 |
  1515. ab3 |
  1516. ab4 |
  1517. ab5 |
  1518. ab6 |
  1519. ab7 |
  1520. ab8 |
  1521. {s:ab0 }{c: }{3:ew][+] }|
  1522. {n:ab1 }{c: } |
  1523. {n:ab2 }{c: } |
  1524. {n:ab3 }{s: } |
  1525. {n:ab4 }{s: } |
  1526. {n:ab5 }{s: } |
  1527. ab0^ |
  1528. {1:~ }|*2
  1529. {4:[No Name] [+] }|
  1530. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 10} |
  1531. ]])
  1532. end)
  1533. end)
  1534. -- oldtest: Test_pum_with_preview_win()
  1535. it('preview window opened during completion', function()
  1536. exec([[
  1537. funct Omni_test(findstart, base)
  1538. if a:findstart
  1539. return col(".") - 1
  1540. endif
  1541. return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}]
  1542. endfunc
  1543. set omnifunc=Omni_test
  1544. set completeopt+=longest
  1545. ]])
  1546. feed('Gi<C-X><C-O>')
  1547. screen:expect([[
  1548. ^ |
  1549. {n:one }{1: }|
  1550. {n:two }{1: }|
  1551. {n:three }{1: }|
  1552. {1:~ }|*15
  1553. {2:-- }{8:Back at original} |
  1554. ]])
  1555. feed('<C-N>')
  1556. screen:expect([[
  1557. 1info |
  1558. {1:~ }|*2
  1559. {3:[Scratch] [Preview] }|
  1560. one^ |
  1561. {s:one }{1: }|
  1562. {n:two }{1: }|
  1563. {n:three }{1: }|
  1564. {1:~ }|*10
  1565. {4:[No Name] [+] }|
  1566. {2:-- }{5:match 1 of 3} |
  1567. ]])
  1568. end)
  1569. -- oldtest: Test_scrollbar_on_wide_char()
  1570. it('scrollbar overwrites half of double-width char below properly', function()
  1571. screen:try_resize(32, 10)
  1572. exec([[
  1573. call setline(1, ['a', ' 啊啊啊',
  1574. \ ' 哦哦哦',
  1575. \ ' 呃呃呃'])
  1576. call setline(5, range(10)->map({i, v -> 'aa' .. v .. 'bb'}))
  1577. ]])
  1578. feed('A<C-X><C-N>')
  1579. screen:expect([[
  1580. aa0bb^ |
  1581. {s:aa0bb }{c: }啊 |
  1582. {n:aa1bb }{c: } 哦 |
  1583. {n:aa2bb }{c: }呃呃 |
  1584. {n:aa3bb }{c: } |
  1585. {n:aa4bb }{c: } |
  1586. {n:aa5bb }{c: } |
  1587. {n:aa6bb }{s: } |
  1588. {n:aa7bb }{s: } |
  1589. {2:-- }{5:match 1 of 10} |
  1590. ]])
  1591. end)
  1592. end
  1593. describe('floating window preview popup', function()
  1594. it('pum popup preview', function()
  1595. --row must > 10
  1596. screen:try_resize(40, 11)
  1597. exec([[
  1598. funct Omni_test(findstart, base)
  1599. if a:findstart
  1600. return col(".") - 1
  1601. endif
  1602. return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "looooooooooooooong"}]
  1603. endfunc
  1604. set omnifunc=Omni_test
  1605. set completeopt=menu,popup
  1606. funct Set_info()
  1607. let comp_info = complete_info()
  1608. if comp_info['selected'] == 2
  1609. call nvim__complete_set(comp_info['selected'], {"info": "3info"})
  1610. endif
  1611. endfunc
  1612. funct TsHl()
  1613. let comp_info = complete_info()
  1614. if get(comp_info, 'previewbufnr', 0) > 0
  1615. call v:lua.vim.treesitter.start(comp_info['preview_bufnr'], 'markdown')
  1616. endif
  1617. if comp_info['selected'] == 0
  1618. call nvim__complete_set(comp_info['selected'], {"info": "```lua\nfunction test()\n print('foo')\nend\n```"})
  1619. endif
  1620. endfunc
  1621. augroup Group
  1622. au!
  1623. autocmd CompleteChanged * :call Set_info()
  1624. augroup END
  1625. funct TestTs()
  1626. autocmd! Group
  1627. autocmd CompleteChanged * call TsHl()
  1628. endfunc
  1629. ]])
  1630. feed('Gi<C-x><C-o>')
  1631. --floating preview in right
  1632. if multigrid then
  1633. screen:expect {
  1634. grid = [[
  1635. ## grid 1
  1636. [2:----------------------------------------]|*10
  1637. [3:----------------------------------------]|
  1638. ## grid 2
  1639. one^ |
  1640. {1:~ }|*9
  1641. ## grid 3
  1642. {2:-- }{5:match 1 of 3} |
  1643. ## grid 4
  1644. {n:1info}|
  1645. {n: }|
  1646. ## grid 5
  1647. {s:one }|
  1648. {n:two }|
  1649. {n:looooooooooooooong }|
  1650. ]],
  1651. float_pos = {
  1652. [5] = { -1, 'NW', 2, 1, 0, false, 100 },
  1653. [4] = { 1001, 'NW', 1, 1, 19, false, 50 },
  1654. },
  1655. win_viewport = {
  1656. [2] = {
  1657. win = 1000,
  1658. topline = 0,
  1659. botline = 2,
  1660. curline = 0,
  1661. curcol = 3,
  1662. linecount = 1,
  1663. sum_scroll_delta = 0,
  1664. },
  1665. [4] = {
  1666. win = 1001,
  1667. topline = 0,
  1668. botline = 2,
  1669. curline = 0,
  1670. curcol = 0,
  1671. linecount = 1,
  1672. sum_scroll_delta = 0,
  1673. },
  1674. },
  1675. }
  1676. else
  1677. screen:expect {
  1678. grid = [[
  1679. one^ |
  1680. {s:one }{n:1info}{1: }|
  1681. {n:two }{1: }|
  1682. {n:looooooooooooooong }{1: }|
  1683. {1:~ }|*6
  1684. {2:-- }{5:match 1 of 3} |
  1685. ]],
  1686. }
  1687. end
  1688. -- delete one character make the pum width smaller than before
  1689. -- info window position should be adjusted when popupmenu width changed
  1690. feed('<BS>')
  1691. if multigrid then
  1692. screen:expect({
  1693. grid = [[
  1694. ## grid 1
  1695. [2:----------------------------------------]|*10
  1696. [3:----------------------------------------]|
  1697. ## grid 2
  1698. on^ |
  1699. {1:~ }|*9
  1700. ## grid 3
  1701. {2:-- }{5:match 1 of 3} |
  1702. ## grid 4
  1703. {n:1info}|
  1704. {n: }|
  1705. ## grid 5
  1706. {s:one }|
  1707. ]],
  1708. float_pos = {
  1709. [5] = { -1, 'NW', 2, 1, 0, false, 100 },
  1710. [4] = { 1001, 'NW', 1, 1, 15, false, 50 },
  1711. },
  1712. win_viewport = {
  1713. [2] = {
  1714. win = 1000,
  1715. topline = 0,
  1716. botline = 2,
  1717. curline = 0,
  1718. curcol = 2,
  1719. linecount = 1,
  1720. sum_scroll_delta = 0,
  1721. },
  1722. [4] = {
  1723. win = 1001,
  1724. topline = 0,
  1725. botline = 2,
  1726. curline = 0,
  1727. curcol = 0,
  1728. linecount = 1,
  1729. sum_scroll_delta = 0,
  1730. },
  1731. },
  1732. win_viewport_margins = {
  1733. [2] = {
  1734. bottom = 0,
  1735. left = 0,
  1736. right = 0,
  1737. top = 0,
  1738. win = 1000,
  1739. },
  1740. [4] = {
  1741. bottom = 0,
  1742. left = 0,
  1743. right = 0,
  1744. top = 0,
  1745. win = 1001,
  1746. },
  1747. },
  1748. })
  1749. else
  1750. screen:expect({
  1751. grid = [[
  1752. on^ |
  1753. {s:one }{n:1info}{1: }|
  1754. {1:~ }{n: }{1: }|
  1755. {1:~ }|*7
  1756. {2:-- }{5:match 1 of 3} |
  1757. ]],
  1758. })
  1759. end
  1760. -- when back to original the preview float should be closed.
  1761. feed('<C-P>')
  1762. if multigrid then
  1763. screen:expect({
  1764. grid = [[
  1765. ## grid 1
  1766. [2:----------------------------------------]|*10
  1767. [3:----------------------------------------]|
  1768. ## grid 2
  1769. on^ |
  1770. {1:~ }|*9
  1771. ## grid 3
  1772. {2:-- }{8:Back at original} |
  1773. ## grid 5
  1774. {n:one }|
  1775. ]],
  1776. float_pos = {
  1777. [5] = { -1, 'NW', 2, 1, 0, false, 100 },
  1778. },
  1779. win_viewport = {
  1780. [2] = {
  1781. win = 1000,
  1782. topline = 0,
  1783. botline = 2,
  1784. curline = 0,
  1785. curcol = 2,
  1786. linecount = 1,
  1787. sum_scroll_delta = 0,
  1788. },
  1789. },
  1790. win_viewport_margins = {
  1791. [2] = {
  1792. bottom = 0,
  1793. left = 0,
  1794. right = 0,
  1795. top = 0,
  1796. win = 1000,
  1797. },
  1798. },
  1799. })
  1800. else
  1801. screen:expect({
  1802. grid = [[
  1803. on^ |
  1804. {n:one }{1: }|
  1805. {1:~ }|*8
  1806. {2:-- }{8:Back at original} |
  1807. ]],
  1808. })
  1809. end
  1810. -- test nvim__complete_set_info
  1811. feed('<ESC>S<C-X><C-O><C-N><C-N>')
  1812. if multigrid then
  1813. screen:expect {
  1814. grid = [[
  1815. ## grid 1
  1816. [2:----------------------------------------]|*10
  1817. [3:----------------------------------------]|
  1818. ## grid 2
  1819. looooooooooooooong^ |
  1820. {1:~ }|*9
  1821. ## grid 3
  1822. {2:-- }{5:match 3 of 3} |
  1823. ## grid 5
  1824. {n:one }|
  1825. {n:two }|
  1826. {s:looooooooooooooong }|
  1827. ## grid 7
  1828. {n:3info}|
  1829. {n: }|
  1830. ]],
  1831. float_pos = {
  1832. [5] = { -1, 'NW', 2, 1, 0, false, 100 },
  1833. [7] = { 1003, 'NW', 1, 1, 19, false, 50 },
  1834. },
  1835. win_viewport = {
  1836. [2] = {
  1837. win = 1000,
  1838. topline = 0,
  1839. botline = 2,
  1840. curline = 0,
  1841. curcol = 18,
  1842. linecount = 1,
  1843. sum_scroll_delta = 0,
  1844. },
  1845. [7] = {
  1846. win = 1003,
  1847. topline = 0,
  1848. botline = 2,
  1849. curline = 0,
  1850. curcol = 0,
  1851. linecount = 1,
  1852. sum_scroll_delta = 0,
  1853. },
  1854. },
  1855. }
  1856. else
  1857. screen:expect {
  1858. grid = [[
  1859. looooooooooooooong^ |
  1860. {n:one 3info}{1: }|
  1861. {n:two }{1: }|
  1862. {s:looooooooooooooong }{1: }|
  1863. {1:~ }|*6
  1864. {2:-- }{5:match 3 of 3} |
  1865. ]],
  1866. }
  1867. end
  1868. -- preview in left
  1869. feed('<ESC>cc')
  1870. insert(('test'):rep(5))
  1871. feed('i<C-x><C-o>')
  1872. if multigrid then
  1873. screen:expect {
  1874. grid = [[
  1875. ## grid 1
  1876. [2:----------------------------------------]|*10
  1877. [3:----------------------------------------]|
  1878. ## grid 2
  1879. itesttesttesttesttesone^t |
  1880. {1:~ }|*9
  1881. ## grid 3
  1882. {2:-- }{5:match 1 of 3} |
  1883. ## grid 5
  1884. {s: one }|
  1885. {n: two }|
  1886. {n: looooooooooooooong }|
  1887. ## grid 8
  1888. {n:1info}|
  1889. {n: }|
  1890. ]],
  1891. float_pos = {
  1892. [8] = { 1004, 'NW', 1, 1, 14, false, 50 },
  1893. [5] = { -1, 'NW', 2, 1, 19, false, 100 },
  1894. },
  1895. win_viewport = {
  1896. [2] = {
  1897. win = 1000,
  1898. topline = 0,
  1899. botline = 2,
  1900. curline = 0,
  1901. curcol = 23,
  1902. linecount = 1,
  1903. sum_scroll_delta = 0,
  1904. },
  1905. [8] = {
  1906. win = 1004,
  1907. topline = 0,
  1908. botline = 2,
  1909. curline = 0,
  1910. curcol = 0,
  1911. linecount = 1,
  1912. sum_scroll_delta = 0,
  1913. },
  1914. },
  1915. }
  1916. else
  1917. screen:expect {
  1918. grid = [[
  1919. itesttesttesttesttesone^t |
  1920. {1:~ }{n:1info}{s: one }{1: }|
  1921. {1:~ }{n: two }{1: }|
  1922. {1:~ }{n: looooooooooooooong }{1: }|
  1923. {1:~ }|*6
  1924. {2:-- }{5:match 1 of 3} |
  1925. ]],
  1926. }
  1927. end
  1928. feed('<C-E><Esc>')
  1929. -- works when scroll with treesitter highlight
  1930. command('call TestTs()')
  1931. feed('S<C-x><C-o>')
  1932. if multigrid then
  1933. screen:expect({
  1934. grid = [[
  1935. ## grid 1
  1936. [2:----------------------------------------]|*10
  1937. [3:----------------------------------------]|
  1938. ## grid 2
  1939. one^ |
  1940. {1:~ }|*9
  1941. ## grid 3
  1942. {2:-- }{5:match 1 of 3} |
  1943. ## grid 5
  1944. {s:one }|
  1945. {n:two }|
  1946. {n:looooooooooooooong }|
  1947. ## grid 9
  1948. {n:```lua }|
  1949. {n:function test()}|
  1950. {n: print('foo') }|
  1951. {n:end }|
  1952. {n:``` }|
  1953. {n: }|
  1954. ]],
  1955. float_pos = {
  1956. [5] = { -1, 'NW', 2, 1, 0, false, 100 },
  1957. [9] = { 1005, 'NW', 1, 1, 19, false, 50 },
  1958. },
  1959. win_viewport = {
  1960. [2] = {
  1961. win = 1000,
  1962. topline = 0,
  1963. botline = 2,
  1964. curline = 0,
  1965. curcol = 3,
  1966. linecount = 1,
  1967. sum_scroll_delta = 0,
  1968. },
  1969. [9] = {
  1970. win = 1005,
  1971. topline = 0,
  1972. botline = 6,
  1973. curline = 0,
  1974. curcol = 0,
  1975. linecount = 5,
  1976. sum_scroll_delta = 0,
  1977. },
  1978. },
  1979. win_viewport_margins = {
  1980. [2] = {
  1981. bottom = 0,
  1982. left = 0,
  1983. right = 0,
  1984. top = 0,
  1985. win = 1000,
  1986. },
  1987. [9] = {
  1988. bottom = 0,
  1989. left = 0,
  1990. right = 0,
  1991. top = 0,
  1992. win = 1005,
  1993. },
  1994. },
  1995. })
  1996. else
  1997. screen:expect({
  1998. grid = [[
  1999. one^ |
  2000. {s:one }{n:```lua }{1: }|
  2001. {n:two function test()}{1: }|
  2002. {n:looooooooooooooong print('foo') }{1: }|
  2003. {1:~ }{n:end }{1: }|
  2004. {1:~ }{n:``` }{1: }|
  2005. {1:~ }{n: }{1: }|
  2006. {1:~ }|*3
  2007. {2:-- }{5:match 1 of 3} |
  2008. ]],
  2009. })
  2010. end
  2011. end)
  2012. end)
  2013. it('with vsplits', function()
  2014. screen:try_resize(32, 8)
  2015. insert('aaa aab aac\n')
  2016. feed(':vsplit<cr>')
  2017. if multigrid then
  2018. screen:expect {
  2019. grid = [[
  2020. ## grid 1
  2021. [4:--------------------]│[2:-----------]|*6
  2022. {4:[No Name] [+] }{3:<Name] [+] }|
  2023. [3:--------------------------------]|
  2024. ## grid 2
  2025. aaa aab aac|
  2026. |
  2027. {1:~ }|*4
  2028. ## grid 3
  2029. :vsplit |
  2030. ## grid 4
  2031. aaa aab aac |
  2032. ^ |
  2033. {1:~ }|*4
  2034. ]],
  2035. }
  2036. else
  2037. screen:expect([[
  2038. aaa aab aac │aaa aab aac|
  2039. ^ │ |
  2040. {1:~ }│{1:~ }|*4
  2041. {4:[No Name] [+] }{3:<Name] [+] }|
  2042. :vsplit |
  2043. ]])
  2044. end
  2045. feed('ibbb a<c-x><c-n>')
  2046. if multigrid then
  2047. screen:expect {
  2048. grid = [[
  2049. ## grid 1
  2050. [4:--------------------]│[2:-----------]|*6
  2051. {4:[No Name] [+] }{3:<Name] [+] }|
  2052. [3:--------------------------------]|
  2053. ## grid 2
  2054. aaa aab aac|
  2055. bbb aaa |
  2056. {1:~ }|*4
  2057. ## grid 3
  2058. {2:-- }{5:match 1 of 3} |
  2059. ## grid 4
  2060. aaa aab aac |
  2061. bbb aaa^ |
  2062. {1:~ }|*4
  2063. ## grid 5
  2064. {s: aaa }|
  2065. {n: aab }|
  2066. {n: aac }|
  2067. ]],
  2068. float_pos = {
  2069. [5] = { -1, 'NW', 4, 2, 3, false, 100 },
  2070. },
  2071. }
  2072. else
  2073. screen:expect([[
  2074. aaa aab aac │aaa aab aac|
  2075. bbb aaa^ │bbb aaa |
  2076. {1:~ }{s: aaa }{1: }│{1:~ }|
  2077. {1:~ }{n: aab }{1: }│{1:~ }|
  2078. {1:~ }{n: aac }{1: }│{1:~ }|
  2079. {1:~ }│{1:~ }|
  2080. {4:[No Name] [+] }{3:<Name] [+] }|
  2081. {2:-- }{5:match 1 of 3} |
  2082. ]])
  2083. end
  2084. feed('<esc><c-w><c-w>oc a<c-x><c-n>')
  2085. if multigrid then
  2086. screen:expect {
  2087. grid = [[
  2088. ## grid 1
  2089. [4:-----------]│[2:--------------------]|*6
  2090. {3:<Name] [+] }{4:[No Name] [+] }|
  2091. [3:--------------------------------]|
  2092. ## grid 2
  2093. aaa aab aac |
  2094. bbb aaa |
  2095. c aaa^ |
  2096. {1:~ }|*3
  2097. ## grid 3
  2098. {2:-- }{5:match 1 of 3} |
  2099. ## grid 4
  2100. aaa aab aac|
  2101. bbb aaa |
  2102. c aaa |
  2103. {1:~ }|*3
  2104. ## grid 5
  2105. {s: aaa }|
  2106. {n: aab }|
  2107. {n: aac }|
  2108. ]],
  2109. float_pos = {
  2110. [5] = { -1, 'NW', 2, 3, 1, false, 100 },
  2111. },
  2112. }
  2113. else
  2114. screen:expect([[
  2115. aaa aab aac│aaa aab aac |
  2116. bbb aaa │bbb aaa |
  2117. c aaa │c aaa^ |
  2118. {1:~ }│{1:~}{s: aaa }{1: }|
  2119. {1:~ }│{1:~}{n: aab }{1: }|
  2120. {1:~ }│{1:~}{n: aac }{1: }|
  2121. {3:<Name] [+] }{4:[No Name] [+] }|
  2122. {2:-- }{5:match 1 of 3} |
  2123. ]])
  2124. end
  2125. feed('bcdef ccc a<c-x><c-n>')
  2126. if multigrid then
  2127. screen:expect {
  2128. grid = [[
  2129. ## grid 1
  2130. [4:-----------]│[2:--------------------]|*6
  2131. {3:<Name] [+] }{4:[No Name] [+] }|
  2132. [3:--------------------------------]|
  2133. ## grid 2
  2134. aaa aab aac |
  2135. bbb aaa |
  2136. c aaabcdef ccc aaa^ |
  2137. {1:~ }|*3
  2138. ## grid 3
  2139. {2:-- }{5:match 1 of 4} |
  2140. ## grid 4
  2141. aaa aab aac|
  2142. bbb aaa |
  2143. c aaabcdef |
  2144. ccc aaa |
  2145. {1:~ }|*2
  2146. ## grid 5
  2147. {s: aaa }|
  2148. {n: aab }|
  2149. {n: aac }|
  2150. {n: aaabcdef}|
  2151. ]],
  2152. float_pos = {
  2153. [5] = { -1, 'NW', 2, 3, 11, false, 100 },
  2154. },
  2155. }
  2156. else
  2157. screen:expect([[
  2158. aaa aab aac│aaa aab aac |
  2159. bbb aaa │bbb aaa |
  2160. c aaabcdef │c aaabcdef ccc aaa^ |
  2161. ccc aaa │{1:~ }{s: aaa }|
  2162. {1:~ }│{1:~ }{n: aab }|
  2163. {1:~ }│{1:~ }{n: aac }|
  2164. {3:<Name] [+] }{4:[No Name] [}{n: aaabcdef}|
  2165. {2:-- }{5:match 1 of 4} |
  2166. ]])
  2167. end
  2168. feed('\n<c-x><c-n>')
  2169. if multigrid then
  2170. screen:expect {
  2171. grid = [[
  2172. ## grid 1
  2173. [4:-----------]│[2:--------------------]|*6
  2174. {3:<Name] [+] }{4:[No Name] [+] }|
  2175. [3:--------------------------------]|
  2176. ## grid 2
  2177. aaa aab aac |
  2178. bbb aaa |
  2179. c aaabcdef ccc aaa |
  2180. aaa^ |
  2181. {1:~ }|*2
  2182. ## grid 3
  2183. {2:-- }{5:match 1 of 6} |
  2184. ## grid 4
  2185. aaa aab aac|
  2186. bbb aaa |
  2187. c aaabcdef |
  2188. ccc aaa |
  2189. aaa |
  2190. {1:~ }|
  2191. ## grid 5
  2192. {s: aaa }{c: }|
  2193. {n: aab }{s: }|
  2194. {n: aac }{s: }|
  2195. ]],
  2196. float_pos = {
  2197. [5] = { -1, 'NW', 2, 4, -1, false, 100 },
  2198. },
  2199. }
  2200. else
  2201. screen:expect([[
  2202. aaa aab aac│aaa aab aac |
  2203. bbb aaa │bbb aaa |
  2204. c aaabcdef │c aaabcdef ccc aaa |
  2205. ccc aaa │aaa^ |
  2206. aaa {s: aaa }{c: }{1: }|
  2207. {1:~ }{n: aab }{s: }{1: }|
  2208. {3:<Name] [+] }{n: aac }{s: }{4: }|
  2209. {2:-- }{5:match 1 of 6} |
  2210. ]])
  2211. end
  2212. end)
  2213. if not multigrid then
  2214. it('with split and scroll', function()
  2215. screen:try_resize(60, 14)
  2216. command('split')
  2217. command('set completeopt+=noinsert')
  2218. command('set mouse=a')
  2219. insert([[
  2220. Lorem ipsum dolor sit amet, consectetur
  2221. adipisicing elit, sed do eiusmod tempor
  2222. incididunt ut labore et dolore magna aliqua.
  2223. Ut enim ad minim veniam, quis nostrud
  2224. exercitation ullamco laboris nisi ut aliquip ex
  2225. ea commodo consequat. Duis aute irure dolor in
  2226. reprehenderit in voluptate velit esse cillum
  2227. dolore eu fugiat nulla pariatur. Excepteur sint
  2228. occaecat cupidatat non proident, sunt in culpa
  2229. qui officia deserunt mollit anim id est
  2230. laborum.
  2231. ]])
  2232. screen:expect([[
  2233. reprehenderit in voluptate velit esse cillum |
  2234. dolore eu fugiat nulla pariatur. Excepteur sint |
  2235. occaecat cupidatat non proident, sunt in culpa |
  2236. qui officia deserunt mollit anim id est |
  2237. laborum. |
  2238. ^ |
  2239. {4:[No Name] [+] }|
  2240. Lorem ipsum dolor sit amet, consectetur |
  2241. adipisicing elit, sed do eiusmod tempor |
  2242. incididunt ut labore et dolore magna aliqua. |
  2243. Ut enim ad minim veniam, quis nostrud |
  2244. exercitation ullamco laboris nisi ut aliquip ex |
  2245. {3:[No Name] [+] }|
  2246. |
  2247. ]])
  2248. feed('ggOEst <c-x><c-p>')
  2249. screen:expect([[
  2250. Est ^ |
  2251. L{n: sunt }{s: }sit amet, consectetur |
  2252. a{n: in }{s: }sed do eiusmod tempor |
  2253. i{n: culpa }{s: }re et dolore magna aliqua. |
  2254. U{n: qui }{s: }eniam, quis nostrud |
  2255. e{n: officia }{s: }co laboris nisi ut aliquip ex |
  2256. {4:[No}{n: deserunt }{s: }{4: }|
  2257. Est{n: mollit }{s: } |
  2258. L{n: anim }{s: }sit amet, consectetur |
  2259. a{n: id }{s: }sed do eiusmod tempor |
  2260. i{n: est }{s: }re et dolore magna aliqua. |
  2261. U{n: laborum }{c: }eniam, quis nostrud |
  2262. {3:[No}{s: Est }{c: }{3: }|
  2263. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  2264. ]])
  2265. api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
  2266. screen:expect([[
  2267. Est ^ |
  2268. L{n: sunt }{s: }sit amet, consectetur |
  2269. a{n: in }{s: }sed do eiusmod tempor |
  2270. i{n: culpa }{s: }re et dolore magna aliqua. |
  2271. U{n: qui }{s: }eniam, quis nostrud |
  2272. e{n: officia }{s: }co laboris nisi ut aliquip ex |
  2273. {4:[No}{n: deserunt }{s: }{4: }|
  2274. i{n: mollit }{s: }re et dolore magna aliqua. |
  2275. U{n: anim }{s: }eniam, quis nostrud |
  2276. e{n: id }{s: }co laboris nisi ut aliquip ex |
  2277. e{n: est }{s: }at. Duis aute irure dolor in |
  2278. r{n: laborum }{c: }oluptate velit esse cillum |
  2279. {3:[No}{s: Est }{c: }{3: }|
  2280. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  2281. ]])
  2282. feed('e')
  2283. screen:expect([[
  2284. Est e^ |
  2285. L{n: elit } sit amet, consectetur |
  2286. a{n: eiusmod } sed do eiusmod tempor |
  2287. i{n: et }ore et dolore magna aliqua. |
  2288. U{n: enim }veniam, quis nostrud |
  2289. e{n: exercitation }mco laboris nisi ut aliquip ex |
  2290. {4:[No}{n: ex }{4: }|
  2291. i{n: ea }ore et dolore magna aliqua. |
  2292. U{n: esse }veniam, quis nostrud |
  2293. e{n: eu }mco laboris nisi ut aliquip ex |
  2294. e{s: est }uat. Duis aute irure dolor in |
  2295. reprehenderit in voluptate velit esse cillum |
  2296. {3:[No Name] [+] }|
  2297. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  2298. ]])
  2299. api.nvim_input_mouse('wheel', 'up', '', 0, 9, 40)
  2300. screen:expect([[
  2301. Est e^ |
  2302. L{n: elit } sit amet, consectetur |
  2303. a{n: eiusmod } sed do eiusmod tempor |
  2304. i{n: et }ore et dolore magna aliqua. |
  2305. U{n: enim }veniam, quis nostrud |
  2306. e{n: exercitation }mco laboris nisi ut aliquip ex |
  2307. {4:[No}{n: ex }{4: }|
  2308. Est{n: ea } |
  2309. L{n: esse } sit amet, consectetur |
  2310. a{n: eu } sed do eiusmod tempor |
  2311. i{s: est }ore et dolore magna aliqua. |
  2312. Ut enim ad minim veniam, quis nostrud |
  2313. {3:[No Name] [+] }|
  2314. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  2315. ]])
  2316. feed('s')
  2317. screen:expect([[
  2318. Est es^ |
  2319. L{n: esse } sit amet, consectetur |
  2320. a{s: est } sed do eiusmod tempor |
  2321. incididunt ut labore et dolore magna aliqua. |
  2322. Ut enim ad minim veniam, quis nostrud |
  2323. exercitation ullamco laboris nisi ut aliquip ex |
  2324. {4:[No Name] [+] }|
  2325. Est es |
  2326. Lorem ipsum dolor sit amet, consectetur |
  2327. adipisicing elit, sed do eiusmod tempor |
  2328. incididunt ut labore et dolore magna aliqua. |
  2329. Ut enim ad minim veniam, quis nostrud |
  2330. {3:[No Name] [+] }|
  2331. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  2332. ]])
  2333. api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
  2334. screen:expect([[
  2335. Est es^ |
  2336. L{n: esse } sit amet, consectetur |
  2337. a{s: est } sed do eiusmod tempor |
  2338. incididunt ut labore et dolore magna aliqua. |
  2339. Ut enim ad minim veniam, quis nostrud |
  2340. exercitation ullamco laboris nisi ut aliquip ex |
  2341. {4:[No Name] [+] }|
  2342. incididunt ut labore et dolore magna aliqua. |
  2343. Ut enim ad minim veniam, quis nostrud |
  2344. exercitation ullamco laboris nisi ut aliquip ex |
  2345. ea commodo consequat. Duis aute irure dolor in |
  2346. reprehenderit in voluptate velit esse cillum |
  2347. {3:[No Name] [+] }|
  2348. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  2349. ]])
  2350. feed('<bs>')
  2351. screen:expect([[
  2352. Est e^ |
  2353. L{n: elit } sit amet, consectetur |
  2354. a{n: eiusmod } sed do eiusmod tempor |
  2355. i{n: et }ore et dolore magna aliqua. |
  2356. U{n: enim }veniam, quis nostrud |
  2357. e{n: exercitation }mco laboris nisi ut aliquip ex |
  2358. {4:[No}{n: ex }{4: }|
  2359. i{n: ea }ore et dolore magna aliqua. |
  2360. U{n: esse }veniam, quis nostrud |
  2361. e{n: eu }mco laboris nisi ut aliquip ex |
  2362. e{s: est }uat. Duis aute irure dolor in |
  2363. reprehenderit in voluptate velit esse cillum |
  2364. {3:[No Name] [+] }|
  2365. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
  2366. ]])
  2367. feed('<c-p>')
  2368. screen:expect([[
  2369. Est eu^ |
  2370. L{n: elit } sit amet, consectetur |
  2371. a{n: eiusmod } sed do eiusmod tempor |
  2372. i{n: et }ore et dolore magna aliqua. |
  2373. U{n: enim }veniam, quis nostrud |
  2374. e{n: exercitation }mco laboris nisi ut aliquip ex |
  2375. {4:[No}{n: ex }{4: }|
  2376. i{n: ea }ore et dolore magna aliqua. |
  2377. U{n: esse }veniam, quis nostrud |
  2378. e{s: eu }mco laboris nisi ut aliquip ex |
  2379. e{n: est }uat. Duis aute irure dolor in |
  2380. reprehenderit in voluptate velit esse cillum |
  2381. {3:[No Name] [+] }|
  2382. {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} |
  2383. ]])
  2384. api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
  2385. screen:expect([[
  2386. Est eu^ |
  2387. L{n: elit } sit amet, consectetur |
  2388. a{n: eiusmod } sed do eiusmod tempor |
  2389. i{n: et }ore et dolore magna aliqua. |
  2390. U{n: enim }veniam, quis nostrud |
  2391. e{n: exercitation }mco laboris nisi ut aliquip ex |
  2392. {4:[No}{n: ex }{4: }|
  2393. e{n: ea }uat. Duis aute irure dolor in |
  2394. r{n: esse }voluptate velit esse cillum |
  2395. d{s: eu }nulla pariatur. Excepteur sint |
  2396. o{n: est }t non proident, sunt in culpa |
  2397. qui officia deserunt mollit anim id est |
  2398. {3:[No Name] [+] }|
  2399. {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} |
  2400. ]])
  2401. fn.complete(4, { 'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' })
  2402. screen:expect([[
  2403. Est eu^ |
  2404. {s: ea }t amet, consectetur |
  2405. {n: eeeeeeeeeeeeeeeeee }d do eiusmod tempor |
  2406. {n: ei } et dolore magna aliqua. |
  2407. {n: eo }iam, quis nostrud |
  2408. {n: eu } laboris nisi ut aliquip ex |
  2409. {4:[N}{n: ey }{4: }|
  2410. {n: eå }. Duis aute irure dolor in |
  2411. {n: eä }uptate velit esse cillum |
  2412. {n: eö }la pariatur. Excepteur sint |
  2413. occaecat cupidatat non proident, sunt in culpa |
  2414. qui officia deserunt mollit anim id est |
  2415. {3:[No Name] [+] }|
  2416. {2:-- Keyword Local completion (^N^P) }{5:match 1 of 9} |
  2417. ]])
  2418. fn.complete(4, { 'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' })
  2419. screen:expect([[
  2420. Est eu^ |
  2421. {s: ea }r sit amet, consectetur |
  2422. {n: eee }, sed do eiusmod tempor |
  2423. {n: ei }bore et dolore magna aliqua. |
  2424. {n: eo } veniam, quis nostrud |
  2425. {n: eu }amco laboris nisi ut aliquip ex |
  2426. {4:[N}{n: ey }{4: }|
  2427. {n: eå }quat. Duis aute irure dolor in |
  2428. {n: eä } voluptate velit esse cillum |
  2429. {n: eö } nulla pariatur. Excepteur sint |
  2430. occaecat cupidatat non proident, sunt in culpa |
  2431. qui officia deserunt mollit anim id est |
  2432. {3:[No Name] [+] }|
  2433. {2:-- INSERT --} |
  2434. ]])
  2435. feed('<c-n>')
  2436. screen:expect([[
  2437. Esteee^ |
  2438. {n: ea }r sit amet, consectetur |
  2439. {s: eee }, sed do eiusmod tempor |
  2440. {n: ei }bore et dolore magna aliqua. |
  2441. {n: eo } veniam, quis nostrud |
  2442. {n: eu }amco laboris nisi ut aliquip ex |
  2443. {4:[N}{n: ey }{4: }|
  2444. {n: eå }quat. Duis aute irure dolor in |
  2445. {n: eä } voluptate velit esse cillum |
  2446. {n: eö } nulla pariatur. Excepteur sint |
  2447. occaecat cupidatat non proident, sunt in culpa |
  2448. qui officia deserunt mollit anim id est |
  2449. {3:[No Name] [+] }|
  2450. {2:-- INSERT --} |
  2451. ]])
  2452. fn.complete(6, { 'foo', 'bar' })
  2453. screen:expect([[
  2454. Esteee^ |
  2455. Lo{s: foo }sit amet, consectetur |
  2456. ad{n: bar }sed do eiusmod tempor |
  2457. incididunt ut labore et dolore magna aliqua. |
  2458. Ut enim ad minim veniam, quis nostrud |
  2459. exercitation ullamco laboris nisi ut aliquip ex |
  2460. {4:[No Name] [+] }|
  2461. ea commodo consequat. Duis aute irure dolor in |
  2462. reprehenderit in voluptate velit esse cillum |
  2463. dolore eu fugiat nulla pariatur. Excepteur sint |
  2464. occaecat cupidatat non proident, sunt in culpa |
  2465. qui officia deserunt mollit anim id est |
  2466. {3:[No Name] [+] }|
  2467. {2:-- INSERT --} |
  2468. ]])
  2469. feed('<c-y>')
  2470. screen:expect([[
  2471. Esteefoo^ |
  2472. Lorem ipsum dolor sit amet, consectetur |
  2473. adipisicing elit, sed do eiusmod tempor |
  2474. incididunt ut labore et dolore magna aliqua. |
  2475. Ut enim ad minim veniam, quis nostrud |
  2476. exercitation ullamco laboris nisi ut aliquip ex |
  2477. {4:[No Name] [+] }|
  2478. ea commodo consequat. Duis aute irure dolor in |
  2479. reprehenderit in voluptate velit esse cillum |
  2480. dolore eu fugiat nulla pariatur. Excepteur sint |
  2481. occaecat cupidatat non proident, sunt in culpa |
  2482. qui officia deserunt mollit anim id est |
  2483. {3:[No Name] [+] }|
  2484. {2:-- INSERT --} |
  2485. ]])
  2486. end)
  2487. it('can be moved due to wrap or resize', function()
  2488. feed('isome long prefix before the ')
  2489. command('set completeopt+=noinsert,noselect')
  2490. command('set linebreak')
  2491. fn.complete(29, { 'word', 'choice', 'text', 'thing' })
  2492. screen:expect([[
  2493. some long prefix before the ^ |
  2494. {1:~ }{n: word }|
  2495. {1:~ }{n: choice}|
  2496. {1:~ }{n: text }|
  2497. {1:~ }{n: thing }|
  2498. {1:~ }|*14
  2499. {2:-- INSERT --} |
  2500. ]])
  2501. feed('<c-p>')
  2502. screen:expect([[
  2503. some long prefix before the |
  2504. thing^ |
  2505. {n:word }{1: }|
  2506. {n:choice }{1: }|
  2507. {n:text }{1: }|
  2508. {s:thing }{1: }|
  2509. {1:~ }|*13
  2510. {2:-- INSERT --} |
  2511. ]])
  2512. feed('<c-p>')
  2513. screen:expect([[
  2514. some long prefix before the text|
  2515. {1:^~ }{n: word }|
  2516. {1:~ }{n: choice}|
  2517. {1:~ }{s: text }|
  2518. {1:~ }{n: thing }|
  2519. {1:~ }|*14
  2520. {2:-- INSERT --} |
  2521. ]])
  2522. screen:try_resize(30, 8)
  2523. screen:expect([[
  2524. some long prefix before the |
  2525. text^ |
  2526. {n:word }{1: }|
  2527. {n:choice }{1: }|
  2528. {s:text }{1: }|
  2529. {n:thing }{1: }|
  2530. {1:~ }|
  2531. {2:-- INSERT --} |
  2532. ]])
  2533. screen:try_resize(50, 8)
  2534. screen:expect([[
  2535. some long prefix before the text^ |
  2536. {1:~ }{n: word }{1: }|
  2537. {1:~ }{n: choice }{1: }|
  2538. {1:~ }{s: text }{1: }|
  2539. {1:~ }{n: thing }{1: }|
  2540. {1:~ }|*2
  2541. {2:-- INSERT --} |
  2542. ]])
  2543. screen:try_resize(25, 10)
  2544. screen:expect([[
  2545. some long prefix before |
  2546. the text^ |
  2547. {1:~ }{n: word }{1: }|
  2548. {1:~ }{n: choice }{1: }|
  2549. {1:~ }{s: text }{1: }|
  2550. {1:~ }{n: thing }{1: }|
  2551. {1:~ }|*3
  2552. {2:-- INSERT --} |
  2553. ]])
  2554. screen:try_resize(12, 5)
  2555. screen:expect([[
  2556. some long |
  2557. prefix |
  2558. bef{n: word } |
  2559. tex{n: }^ |
  2560. {2:-- INSERT --}|
  2561. ]])
  2562. -- can't draw the pum, but check we don't crash
  2563. screen:try_resize(12, 2)
  2564. screen:expect([[
  2565. {1:<<<}t^ |
  2566. {2:-- INSERT --}|
  2567. ]])
  2568. -- but state is preserved, pum reappears
  2569. screen:try_resize(20, 8)
  2570. screen:expect([[
  2571. some long prefix |
  2572. before the text^ |
  2573. {1:~ }{n: word }{1: }|
  2574. {1:~ }{n: choice }{1: }|
  2575. {1:~ }{s: text }{1: }|
  2576. {1:~ }{n: thing }{1: }|
  2577. {1:~ }|
  2578. {2:-- INSERT --} |
  2579. ]])
  2580. end)
  2581. it('with VimResized autocmd', function()
  2582. feed('isome long prefix before the ')
  2583. command('set completeopt+=noinsert,noselect')
  2584. command('autocmd VimResized * redraw!')
  2585. command('set linebreak')
  2586. fn.complete(29, { 'word', 'choice', 'text', 'thing' })
  2587. screen:expect([[
  2588. some long prefix before the ^ |
  2589. {1:~ }{n: word }|
  2590. {1:~ }{n: choice}|
  2591. {1:~ }{n: text }|
  2592. {1:~ }{n: thing }|
  2593. {1:~ }|*14
  2594. {2:-- INSERT --} |
  2595. ]])
  2596. screen:try_resize(16, 10)
  2597. screen:expect([[
  2598. some long |
  2599. prefix before |
  2600. the ^ |
  2601. {1:~ }{n: word }|
  2602. {1:~ }{n: choice }|
  2603. {1:~ }{n: text }|
  2604. {1:~ }{n: thing }|
  2605. {1:~ }|*2
  2606. {2:-- INSERT --} |
  2607. ]])
  2608. end)
  2609. it('with rightleft window', function()
  2610. command('set rl wildoptions+=pum')
  2611. feed('isome rightleft ')
  2612. screen:expect([[
  2613. ^ tfelthgir emos|
  2614. {1: ~}|*18
  2615. {2:-- INSERT --} |
  2616. ]])
  2617. command('set completeopt+=noinsert,noselect')
  2618. fn.complete(16, { 'word', 'choice', 'text', 'thing' })
  2619. screen:expect([[
  2620. ^ tfelthgir emos|
  2621. {1: }{n: drow }{1: ~}|
  2622. {1: }{n: eciohc }{1: ~}|
  2623. {1: }{n: txet }{1: ~}|
  2624. {1: }{n: gniht }{1: ~}|
  2625. {1: ~}|*14
  2626. {2:-- INSERT --} |
  2627. ]])
  2628. feed('<c-n>')
  2629. screen:expect([[
  2630. ^ drow tfelthgir emos|
  2631. {1: }{s: drow }{1: ~}|
  2632. {1: }{n: eciohc }{1: ~}|
  2633. {1: }{n: txet }{1: ~}|
  2634. {1: }{n: gniht }{1: ~}|
  2635. {1: ~}|*14
  2636. {2:-- INSERT --} |
  2637. ]])
  2638. feed('<c-y>')
  2639. screen:expect([[
  2640. ^ drow tfelthgir emos|
  2641. {1: ~}|*18
  2642. {2:-- INSERT --} |
  2643. ]])
  2644. -- not rightleft on the cmdline
  2645. feed('<esc>:sign ')
  2646. screen:expect {
  2647. grid = [[
  2648. drow tfelthgir emos|
  2649. {1: ~}|*18
  2650. :sign ^ |
  2651. ]],
  2652. }
  2653. -- oldtest: Test_wildmenu_pum_rightleft()
  2654. feed('<tab>')
  2655. screen:expect {
  2656. grid = [[
  2657. drow tfelthgir emos|
  2658. {1: ~}|*12
  2659. {1: }{s: define }{1: ~}|
  2660. {1: }{n: jump }{1: ~}|
  2661. {1: }{n: list }{1: ~}|
  2662. {1: }{n: place }{1: ~}|
  2663. {1: }{n: undefine }{1: ~}|
  2664. {1: }{n: unplace }{1: ~}|
  2665. :sign define^ |
  2666. ]],
  2667. }
  2668. end)
  2669. end
  2670. it('with rightleft vsplits', function()
  2671. screen:try_resize(40, 6)
  2672. command('set rightleft')
  2673. command('rightbelow vsplit')
  2674. command('set completeopt+=noinsert,noselect')
  2675. command('set pumheight=2')
  2676. feed('isome rightleft ')
  2677. fn.complete(16, { 'word', 'choice', 'text', 'thing' })
  2678. if multigrid then
  2679. screen:expect {
  2680. grid = [[
  2681. ## grid 1
  2682. [2:-------------------]│[4:--------------------]|*4
  2683. {3:[No Name] [+] }{4:[No Name] [+] }|
  2684. [3:----------------------------------------]|
  2685. ## grid 2
  2686. tfelthgir emos|
  2687. {1: ~}|*3
  2688. ## grid 3
  2689. {2:-- INSERT --} |
  2690. ## grid 4
  2691. ^ tfelthgir emos|
  2692. {1: ~}|*3
  2693. ## grid 5
  2694. {c: }{n: drow }|
  2695. {s: }{n: eciohc }|
  2696. ]],
  2697. float_pos = {
  2698. [5] = { -1, 'NW', 4, 1, -11, false, 100 },
  2699. },
  2700. }
  2701. else
  2702. screen:expect([[
  2703. tfelthgir emos│ ^ tfelthgir emos|
  2704. {1: }{c: }{n: drow }{1: ~}|
  2705. {1: }{s: }{n: eciohc }{1: ~}|
  2706. {1: ~}│{1: ~}|
  2707. {3:[No Name] [+] }{4:[No Name] [+] }|
  2708. {2:-- INSERT --} |
  2709. ]])
  2710. end
  2711. feed('<C-E><CR>')
  2712. fn.complete(1, { 'word', 'choice', 'text', 'thing' })
  2713. if multigrid then
  2714. screen:expect {
  2715. grid = [[
  2716. ## grid 1
  2717. [2:-------------------]│[4:--------------------]|*4
  2718. {3:[No Name] [+] }{4:[No Name] [+] }|
  2719. [3:----------------------------------------]|
  2720. ## grid 2
  2721. tfelthgir emos|
  2722. |
  2723. {1: ~}|*2
  2724. ## grid 3
  2725. {2:-- INSERT --} |
  2726. ## grid 4
  2727. tfelthgir emos|
  2728. ^ |
  2729. {1: ~}|*2
  2730. ## grid 5
  2731. {c: }{n: drow}|
  2732. {s: }{n: eciohc}|
  2733. ]],
  2734. float_pos = {
  2735. [5] = { -1, 'NW', 4, 2, 4, false, 100 },
  2736. },
  2737. }
  2738. else
  2739. screen:expect([[
  2740. tfelthgir emos│ tfelthgir emos|
  2741. │ ^ |
  2742. {1: ~}│{1: }{c: }{n: drow}|
  2743. {1: ~}│{1: }{s: }{n: eciohc}|
  2744. {3:[No Name] [+] }{4:[No Name] [+] }|
  2745. {2:-- INSERT --} |
  2746. ]])
  2747. end
  2748. feed('<C-E>')
  2749. async_meths.nvim_call_function('input', { '', '', 'sign' })
  2750. if multigrid then
  2751. screen:expect {
  2752. grid = [[
  2753. ## grid 1
  2754. [2:-------------------]│[4:--------------------]|*4
  2755. {3:[No Name] [+] }{4:[No Name] [+] }|
  2756. [3:----------------------------------------]|
  2757. ## grid 2
  2758. tfelthgir emos|
  2759. |
  2760. {1: ~}|*2
  2761. ## grid 3
  2762. ^ |
  2763. ## grid 4
  2764. tfelthgir emos|
  2765. |
  2766. {1: ~}|*2
  2767. ]],
  2768. }
  2769. else
  2770. screen:expect([[
  2771. tfelthgir emos│ tfelthgir emos|
  2772. │ |
  2773. {1: ~}│{1: ~}|*2
  2774. {3:[No Name] [+] }{4:[No Name] [+] }|
  2775. ^ |
  2776. ]])
  2777. end
  2778. command('set wildoptions+=pum')
  2779. feed('<Tab>')
  2780. if multigrid then
  2781. screen:expect {
  2782. grid = [[
  2783. ## grid 1
  2784. [2:-------------------]│[4:--------------------]|*4
  2785. {3:[No Name] [+] }{4:[No Name] [+] }|
  2786. [3:----------------------------------------]|
  2787. ## grid 2
  2788. tfelthgir emos|
  2789. |
  2790. {1: ~}|*2
  2791. ## grid 3
  2792. define^ |
  2793. ## grid 4
  2794. tfelthgir emos|
  2795. |
  2796. {1: ~}|*2
  2797. ## grid 5
  2798. {s:define }{c: }|
  2799. {n:jump }{s: }|
  2800. ]],
  2801. float_pos = {
  2802. [5] = { -1, 'SW', 1, 5, 0, false, 250 },
  2803. },
  2804. }
  2805. else
  2806. screen:expect([[
  2807. tfelthgir emos│ tfelthgir emos|
  2808. │ |
  2809. {1: ~}│{1: ~}|
  2810. {s:define }{c: }{1: ~}│{1: ~}|
  2811. {n:jump }{s: }{3: }{4:[No Name] [+] }|
  2812. define^ |
  2813. ]])
  2814. end
  2815. end)
  2816. if not multigrid then
  2817. it('with multiline messages', function()
  2818. screen:try_resize(40, 8)
  2819. feed('ixx<cr>')
  2820. command('imap <f2> <cmd>echoerr "very"\\|echoerr "much"\\|echoerr "error"<cr>')
  2821. fn.complete(1, { 'word', 'choice', 'text', 'thing' })
  2822. screen:expect([[
  2823. xx |
  2824. word^ |
  2825. {s:word }{1: }|
  2826. {n:choice }{1: }|
  2827. {n:text }{1: }|
  2828. {n:thing }{1: }|
  2829. {1:~ }|
  2830. {2:-- INSERT --} |
  2831. ]])
  2832. feed('<f2>')
  2833. screen:expect([[
  2834. xx |
  2835. word |
  2836. {s:word }{1: }|
  2837. {4: }|
  2838. {6:very} |
  2839. {6:much} |
  2840. {6:error} |
  2841. {5:Press ENTER or type command to continue}^ |
  2842. ]])
  2843. feed('<cr>')
  2844. screen:expect([[
  2845. xx |
  2846. word^ |
  2847. {s:word }{1: }|
  2848. {n:choice }{1: }|
  2849. {n:text }{1: }|
  2850. {n:thing }{1: }|
  2851. {1:~ }|
  2852. {2:-- INSERT --} |
  2853. ]])
  2854. feed('<c-n>')
  2855. screen:expect([[
  2856. xx |
  2857. choice^ |
  2858. {n:word }{1: }|
  2859. {s:choice }{1: }|
  2860. {n:text }{1: }|
  2861. {n:thing }{1: }|
  2862. {1:~ }|
  2863. {2:-- INSERT --} |
  2864. ]])
  2865. command('split')
  2866. screen:expect([[
  2867. xx |
  2868. choice^ |
  2869. {n:word }{1: }|
  2870. {s:choice }{4: }|
  2871. {n:text } |
  2872. {n:thing } |
  2873. {3:[No Name] [+] }|
  2874. {2:-- INSERT --} |
  2875. ]])
  2876. api.nvim_input_mouse('wheel', 'down', '', 0, 6, 15)
  2877. screen:expect {
  2878. grid = [[
  2879. xx |
  2880. choice^ |
  2881. {n:word }{1: }|
  2882. {s:choice }{4: }|
  2883. {n:text } |
  2884. {n:thing }{1: }|
  2885. {3:[No Name] [+] }|
  2886. {2:-- INSERT --} |
  2887. ]],
  2888. unchanged = true,
  2889. }
  2890. end)
  2891. it('with kind, menu and abbr attributes', function()
  2892. screen:try_resize(40, 8)
  2893. feed('ixx ')
  2894. fn.complete(4, {
  2895. { word = 'wordey', kind = 'x', menu = 'extrainfo' },
  2896. 'thing',
  2897. { word = 'secret', abbr = 'sneaky', menu = 'bar' },
  2898. })
  2899. screen:expect([[
  2900. xx wordey^ |
  2901. {1:~ }{s: wordey x extrainfo }{1: }|
  2902. {1:~ }{n: thing }{1: }|
  2903. {1:~ }{n: sneaky bar }{1: }|
  2904. {1:~ }|*3
  2905. {2:-- INSERT --} |
  2906. ]])
  2907. feed('<c-p>')
  2908. screen:expect([[
  2909. xx ^ |
  2910. {1:~ }{n: wordey x extrainfo }{1: }|
  2911. {1:~ }{n: thing }{1: }|
  2912. {1:~ }{n: sneaky bar }{1: }|
  2913. {1:~ }|*3
  2914. {2:-- INSERT --} |
  2915. ]])
  2916. feed('<c-p>')
  2917. screen:expect([[
  2918. xx secret^ |
  2919. {1:~ }{n: wordey x extrainfo }{1: }|
  2920. {1:~ }{n: thing }{1: }|
  2921. {1:~ }{s: sneaky bar }{1: }|
  2922. {1:~ }|*3
  2923. {2:-- INSERT --} |
  2924. ]])
  2925. feed('<esc>')
  2926. screen:expect([[
  2927. xx secre^t |
  2928. {1:~ }|*6
  2929. |
  2930. ]])
  2931. end)
  2932. it('wildoptions=pum', function()
  2933. screen:try_resize(32, 10)
  2934. command('set wildmenu')
  2935. command('set wildoptions=pum')
  2936. command('set shellslash')
  2937. command('cd test/functional/fixtures/wildpum')
  2938. feed(':sign ')
  2939. screen:expect([[
  2940. |
  2941. {1:~ }|*8
  2942. :sign ^ |
  2943. ]])
  2944. feed('<Tab>')
  2945. screen:expect([[
  2946. |
  2947. {1:~ }|*2
  2948. {1:~ }{s: define }{1: }|
  2949. {1:~ }{n: jump }{1: }|
  2950. {1:~ }{n: list }{1: }|
  2951. {1:~ }{n: place }{1: }|
  2952. {1:~ }{n: undefine }{1: }|
  2953. {1:~ }{n: unplace }{1: }|
  2954. :sign define^ |
  2955. ]])
  2956. feed('<Right><Right>')
  2957. screen:expect([[
  2958. |
  2959. {1:~ }|*2
  2960. {1:~ }{n: define }{1: }|
  2961. {1:~ }{n: jump }{1: }|
  2962. {1:~ }{s: list }{1: }|
  2963. {1:~ }{n: place }{1: }|
  2964. {1:~ }{n: undefine }{1: }|
  2965. {1:~ }{n: unplace }{1: }|
  2966. :sign list^ |
  2967. ]])
  2968. feed('<C-N>')
  2969. screen:expect([[
  2970. |
  2971. {1:~ }|*2
  2972. {1:~ }{n: define }{1: }|
  2973. {1:~ }{n: jump }{1: }|
  2974. {1:~ }{n: list }{1: }|
  2975. {1:~ }{s: place }{1: }|
  2976. {1:~ }{n: undefine }{1: }|
  2977. {1:~ }{n: unplace }{1: }|
  2978. :sign place^ |
  2979. ]])
  2980. feed('<C-P>')
  2981. screen:expect([[
  2982. |
  2983. {1:~ }|*2
  2984. {1:~ }{n: define }{1: }|
  2985. {1:~ }{n: jump }{1: }|
  2986. {1:~ }{s: list }{1: }|
  2987. {1:~ }{n: place }{1: }|
  2988. {1:~ }{n: undefine }{1: }|
  2989. {1:~ }{n: unplace }{1: }|
  2990. :sign list^ |
  2991. ]])
  2992. feed('<Left>')
  2993. screen:expect([[
  2994. |
  2995. {1:~ }|*2
  2996. {1:~ }{n: define }{1: }|
  2997. {1:~ }{s: jump }{1: }|
  2998. {1:~ }{n: list }{1: }|
  2999. {1:~ }{n: place }{1: }|
  3000. {1:~ }{n: undefine }{1: }|
  3001. {1:~ }{n: unplace }{1: }|
  3002. :sign jump^ |
  3003. ]])
  3004. -- pressing <C-E> should end completion and go back to the original match
  3005. feed('<C-E>')
  3006. screen:expect([[
  3007. |
  3008. {1:~ }|*8
  3009. :sign ^ |
  3010. ]])
  3011. -- pressing <C-Y> should select the current match and end completion
  3012. feed('<Tab><C-P><C-P><C-Y>')
  3013. screen:expect([[
  3014. |
  3015. {1:~ }|*8
  3016. :sign unplace^ |
  3017. ]])
  3018. -- showing popup menu in different columns in the cmdline
  3019. feed('<C-U>sign define <Tab>')
  3020. screen:expect([[
  3021. |
  3022. {1:~ }|
  3023. {1:~ }{s: culhl= }{1: }|
  3024. {1:~ }{n: icon= }{1: }|
  3025. {1:~ }{n: linehl= }{1: }|
  3026. {1:~ }{n: numhl= }{1: }|
  3027. {1:~ }{n: priority= }{1: }|
  3028. {1:~ }{n: text= }{1: }|
  3029. {1:~ }{n: texthl= }{1: }|
  3030. :sign define culhl=^ |
  3031. ]])
  3032. feed('<Space><Tab>')
  3033. screen:expect([[
  3034. |
  3035. {1:~ }|
  3036. {1:~ }{s: culhl= }{1: }|
  3037. {1:~ }{n: icon= }{1: }|
  3038. {1:~ }{n: linehl= }{1: }|
  3039. {1:~ }{n: numhl= }{1: }|
  3040. {1:~ }{n: priority= }{1: }|
  3041. {1:~ }{n: text= }{1: }|
  3042. {1:~ }{n: texthl= }{1: }|
  3043. :sign define culhl= culhl=^ |
  3044. ]])
  3045. feed('<C-U>e Xnamedi<Tab><Tab>')
  3046. screen:expect([[
  3047. |
  3048. {1:~ }|*6
  3049. {1:~ }{s: XdirA/ }{1: }|
  3050. {1:~ }{n: XfileA }{1: }|
  3051. :e Xnamedir/XdirA/^ |
  3052. ]])
  3053. -- Pressing <Down> on a directory name should go into that directory
  3054. feed('<Down>')
  3055. screen:expect([[
  3056. |
  3057. {1:~ }|*6
  3058. {1:~ }{s: XdirB/ }{1: }|
  3059. {1:~ }{n: XfileB }{1: }|
  3060. :e Xnamedir/XdirA/XdirB/^ |
  3061. ]])
  3062. -- Pressing <Up> on a directory name should go to the parent directory
  3063. feed('<Up>')
  3064. screen:expect([[
  3065. |
  3066. {1:~ }|*6
  3067. {1:~ }{s: XdirA/ }{1: }|
  3068. {1:~ }{n: XfileA }{1: }|
  3069. :e Xnamedir/XdirA/^ |
  3070. ]])
  3071. -- Pressing <C-A> when the popup menu is displayed should list all the
  3072. -- matches and remove the popup menu
  3073. feed(':<C-U>sign <Tab><C-A>')
  3074. screen:expect([[
  3075. |
  3076. {1:~ }|*6
  3077. {4: }|
  3078. :sign define jump list place und|
  3079. efine unplace^ |
  3080. ]])
  3081. -- Pressing <Left> after that should move the cursor
  3082. feed('<Left>')
  3083. screen:expect([[
  3084. |
  3085. {1:~ }|*6
  3086. {4: }|
  3087. :sign define jump list place und|
  3088. efine unplac^e |
  3089. ]])
  3090. feed('<End>')
  3091. -- Pressing <C-D> when the popup menu is displayed should remove the popup
  3092. -- menu
  3093. feed('<C-U>sign <Tab><C-D>')
  3094. screen:expect([[
  3095. |
  3096. {1:~ }|*5
  3097. {4: }|
  3098. :sign define |
  3099. define |
  3100. :sign define^ |
  3101. ]])
  3102. -- Pressing <S-Tab> should open the popup menu with the last entry selected
  3103. feed('<C-U><CR>:sign <S-Tab><C-P>')
  3104. screen:expect([[
  3105. |
  3106. {1:~ }|*2
  3107. {1:~ }{n: define }{1: }|
  3108. {1:~ }{n: jump }{1: }|
  3109. {1:~ }{n: list }{1: }|
  3110. {1:~ }{n: place }{1: }|
  3111. {1:~ }{s: undefine }{1: }|
  3112. {1:~ }{n: unplace }{1: }|
  3113. :sign undefine^ |
  3114. ]])
  3115. -- Pressing <Esc> should close the popup menu and cancel the cmd line
  3116. feed('<C-U><CR>:sign <Tab><Esc>')
  3117. screen:expect([[
  3118. ^ |
  3119. {1:~ }|*8
  3120. |
  3121. ]])
  3122. -- Typing a character when the popup is open, should close the popup
  3123. feed(':sign <Tab>x')
  3124. screen:expect([[
  3125. |
  3126. {1:~ }|*8
  3127. :sign definex^ |
  3128. ]])
  3129. -- When the popup is open, entering the cmdline window should close the popup
  3130. feed('<C-U>sign <Tab><C-F>')
  3131. screen:expect([[
  3132. |
  3133. {3:[No Name] }|
  3134. {1::}sign define |
  3135. {1::}sign define^ |
  3136. {1:~ }|*4
  3137. {4:[Command Line] }|
  3138. :sign define |
  3139. ]])
  3140. feed(':q<CR>')
  3141. -- After the last popup menu item, <C-N> should show the original string
  3142. feed(':sign u<Tab><C-N><C-N>')
  3143. screen:expect([[
  3144. |
  3145. {1:~ }|*6
  3146. {1:~ }{n: undefine }{1: }|
  3147. {1:~ }{n: unplace }{1: }|
  3148. :sign u^ |
  3149. ]])
  3150. -- Use the popup menu for the command name
  3151. feed('<C-U>bu<Tab>')
  3152. screen:expect([[
  3153. |
  3154. {1:~ }|*4
  3155. {s: bufdo }{1: }|
  3156. {n: buffer }{1: }|
  3157. {n: buffers }{1: }|
  3158. {n: bunload }{1: }|
  3159. :bufdo^ |
  3160. ]])
  3161. -- Pressing <BS> should remove the popup menu and erase the last character
  3162. feed('<C-E><C-U>sign <Tab><BS>')
  3163. screen:expect([[
  3164. |
  3165. {1:~ }|*8
  3166. :sign defin^ |
  3167. ]])
  3168. -- Pressing <C-W> should remove the popup menu and erase the previous word
  3169. feed('<C-E><C-U>sign <Tab><C-W>')
  3170. screen:expect([[
  3171. |
  3172. {1:~ }|*8
  3173. :sign ^ |
  3174. ]])
  3175. -- Pressing <C-U> should remove the popup menu and erase the entire line
  3176. feed('<C-E><C-U>sign <Tab><C-U>')
  3177. screen:expect([[
  3178. |
  3179. {1:~ }|*8
  3180. :^ |
  3181. ]])
  3182. -- Using <C-E> to cancel the popup menu and then pressing <Up> should recall
  3183. -- the cmdline from history
  3184. feed('sign xyz<Esc>:sign <Tab><C-E><Up>')
  3185. screen:expect([[
  3186. |
  3187. {1:~ }|*8
  3188. :sign xyz^ |
  3189. ]])
  3190. feed('<esc>')
  3191. -- Check "list" still works
  3192. command('set wildmode=longest,list')
  3193. feed(':cn<Tab>')
  3194. screen:expect([[
  3195. |
  3196. {1:~ }|*3
  3197. {4: }|
  3198. :cn |
  3199. cnewer cnoreabbrev |
  3200. cnext cnoremap |
  3201. cnfile cnoremenu |
  3202. :cn^ |
  3203. ]])
  3204. feed('s')
  3205. screen:expect([[
  3206. |
  3207. {1:~ }|*3
  3208. {4: }|
  3209. :cn |
  3210. cnewer cnoreabbrev |
  3211. cnext cnoremap |
  3212. cnfile cnoremenu |
  3213. :cns^ |
  3214. ]])
  3215. feed('<esc>')
  3216. command('set wildmode=full')
  3217. -- Tests a directory name contained full-width characters.
  3218. feed(':e あいう/<Tab>')
  3219. screen:expect([[
  3220. |
  3221. {1:~ }|*5
  3222. {1:~ }{s: 123 }{1: }|
  3223. {1:~ }{n: abc }{1: }|
  3224. {1:~ }{n: xyz }{1: }|
  3225. :e あいう/123^ |
  3226. ]])
  3227. feed('<Esc>')
  3228. -- Pressing <PageDown> should scroll the menu downward
  3229. feed(':sign <Tab><PageDown>')
  3230. screen:expect([[
  3231. |
  3232. {1:~ }|*2
  3233. {1:~ }{n: define }{1: }|
  3234. {1:~ }{n: jump }{1: }|
  3235. {1:~ }{n: list }{1: }|
  3236. {1:~ }{n: place }{1: }|
  3237. {1:~ }{s: undefine }{1: }|
  3238. {1:~ }{n: unplace }{1: }|
  3239. :sign undefine^ |
  3240. ]])
  3241. feed('<PageDown>')
  3242. screen:expect([[
  3243. |
  3244. {1:~ }|*2
  3245. {1:~ }{n: define }{1: }|
  3246. {1:~ }{n: jump }{1: }|
  3247. {1:~ }{n: list }{1: }|
  3248. {1:~ }{n: place }{1: }|
  3249. {1:~ }{n: undefine }{1: }|
  3250. {1:~ }{s: unplace }{1: }|
  3251. :sign unplace^ |
  3252. ]])
  3253. feed('<PageDown>')
  3254. screen:expect([[
  3255. |
  3256. {1:~ }|*2
  3257. {1:~ }{n: define }{1: }|
  3258. {1:~ }{n: jump }{1: }|
  3259. {1:~ }{n: list }{1: }|
  3260. {1:~ }{n: place }{1: }|
  3261. {1:~ }{n: undefine }{1: }|
  3262. {1:~ }{n: unplace }{1: }|
  3263. :sign ^ |
  3264. ]])
  3265. feed('<PageDown>')
  3266. screen:expect([[
  3267. |
  3268. {1:~ }|*2
  3269. {1:~ }{s: define }{1: }|
  3270. {1:~ }{n: jump }{1: }|
  3271. {1:~ }{n: list }{1: }|
  3272. {1:~ }{n: place }{1: }|
  3273. {1:~ }{n: undefine }{1: }|
  3274. {1:~ }{n: unplace }{1: }|
  3275. :sign define^ |
  3276. ]])
  3277. feed('<C-U>sign <Tab><Right><Right><PageDown>')
  3278. screen:expect([[
  3279. |
  3280. {1:~ }|*2
  3281. {1:~ }{n: define }{1: }|
  3282. {1:~ }{n: jump }{1: }|
  3283. {1:~ }{n: list }{1: }|
  3284. {1:~ }{n: place }{1: }|
  3285. {1:~ }{n: undefine }{1: }|
  3286. {1:~ }{s: unplace }{1: }|
  3287. :sign unplace^ |
  3288. ]])
  3289. -- Pressing <PageUp> should scroll the menu upward
  3290. feed('<C-U>sign <Tab><PageUp>')
  3291. screen:expect([[
  3292. |
  3293. {1:~ }|*2
  3294. {1:~ }{n: define }{1: }|
  3295. {1:~ }{n: jump }{1: }|
  3296. {1:~ }{n: list }{1: }|
  3297. {1:~ }{n: place }{1: }|
  3298. {1:~ }{n: undefine }{1: }|
  3299. {1:~ }{n: unplace }{1: }|
  3300. :sign ^ |
  3301. ]])
  3302. feed('<PageUp>')
  3303. screen:expect([[
  3304. |
  3305. {1:~ }|*2
  3306. {1:~ }{n: define }{1: }|
  3307. {1:~ }{n: jump }{1: }|
  3308. {1:~ }{n: list }{1: }|
  3309. {1:~ }{n: place }{1: }|
  3310. {1:~ }{n: undefine }{1: }|
  3311. {1:~ }{s: unplace }{1: }|
  3312. :sign unplace^ |
  3313. ]])
  3314. feed('<PageUp>')
  3315. screen:expect([[
  3316. |
  3317. {1:~ }|*2
  3318. {1:~ }{n: define }{1: }|
  3319. {1:~ }{s: jump }{1: }|
  3320. {1:~ }{n: list }{1: }|
  3321. {1:~ }{n: place }{1: }|
  3322. {1:~ }{n: undefine }{1: }|
  3323. {1:~ }{n: unplace }{1: }|
  3324. :sign jump^ |
  3325. ]])
  3326. feed('<PageUp>')
  3327. screen:expect([[
  3328. |
  3329. {1:~ }|*2
  3330. {1:~ }{s: define }{1: }|
  3331. {1:~ }{n: jump }{1: }|
  3332. {1:~ }{n: list }{1: }|
  3333. {1:~ }{n: place }{1: }|
  3334. {1:~ }{n: undefine }{1: }|
  3335. {1:~ }{n: unplace }{1: }|
  3336. :sign define^ |
  3337. ]])
  3338. -- pressing <C-E> to end completion should work in middle of the line too
  3339. feed('<Esc>:set wildchazz<Left><Left><Tab>')
  3340. screen:expect([[
  3341. |
  3342. {1:~ }|*6
  3343. {1:~ }{s: wildchar }{1: }|
  3344. {1:~ }{n: wildcharm }{1: }|
  3345. :set wildchar^zz |
  3346. ]])
  3347. feed('<C-E>')
  3348. screen:expect([[
  3349. |
  3350. {1:~ }|*8
  3351. :set wildcha^zz |
  3352. ]])
  3353. -- pressing <C-Y> should select the current match and end completion
  3354. feed('<Esc>:set wildchazz<Left><Left><Tab><C-Y>')
  3355. screen:expect([[
  3356. |
  3357. {1:~ }|*8
  3358. :set wildchar^zz |
  3359. ]])
  3360. feed('<Esc>')
  3361. -- check positioning with multibyte char in pattern
  3362. command('e långfile1')
  3363. command('sp långfile2')
  3364. feed(':b lå<tab>')
  3365. screen:expect([[
  3366. |
  3367. {1:~ }|*3
  3368. {4:långfile2 }|
  3369. |
  3370. {1:~ }|
  3371. {1:~ }{s: långfile1 }{1: }|
  3372. {3:lå}{n: långfile2 }{3: }|
  3373. :b långfile1^ |
  3374. ]])
  3375. -- check doesn't crash on screen resize
  3376. screen:try_resize(20, 6)
  3377. screen:expect([[
  3378. |
  3379. {1:~ }|
  3380. {4:långfile2 }|
  3381. {s: långfile1 } |
  3382. {3:lå}{n: långfile2 }{3: }|
  3383. :b långfile1^ |
  3384. ]])
  3385. screen:try_resize(50, 15)
  3386. screen:expect([[
  3387. |
  3388. {1:~ }|
  3389. {4:långfile2 }|
  3390. |
  3391. {1:~ }|*8
  3392. {1:~ }{s: långfile1 }{1: }|
  3393. {3:lå}{n: långfile2 }{3: }|
  3394. :b långfile1^ |
  3395. ]])
  3396. -- position is calculated correctly with "longest"
  3397. feed('<esc>')
  3398. command('set wildmode=longest:full,full')
  3399. feed(':b lå<tab>')
  3400. screen:expect([[
  3401. |
  3402. {1:~ }|
  3403. {4:långfile2 }|
  3404. |
  3405. {1:~ }|*8
  3406. {1:~ }{n: långfile1 }{1: }|
  3407. {3:lå}{n: långfile2 }{3: }|
  3408. :b långfile^ |
  3409. ]])
  3410. feed('<esc>')
  3411. command('close')
  3412. command('set wildmode=full')
  3413. -- special case: when patterns ends with "/", show menu items aligned
  3414. -- after the "/"
  3415. feed(':e compdir/<tab>')
  3416. screen:expect([[
  3417. |
  3418. {1:~ }|*11
  3419. {1:~ }{s: file1 }{1: }|
  3420. {1:~ }{n: file2 }{1: }|
  3421. :e compdir/file1^ |
  3422. ]])
  3423. end)
  3424. it('wildoptions=pum with scrolled messages', function()
  3425. screen:try_resize(40, 10)
  3426. command('set wildmenu')
  3427. command('set wildoptions=pum')
  3428. feed(':echoerr "fail"|echoerr "error"<cr>')
  3429. screen:expect {
  3430. grid = [[
  3431. |
  3432. {1:~ }|*5
  3433. {4: }|
  3434. {6:fail} |
  3435. {6:error} |
  3436. {5:Press ENTER or type command to continue}^ |
  3437. ]],
  3438. }
  3439. feed(':sign <tab>')
  3440. screen:expect {
  3441. grid = [[
  3442. |
  3443. {1:~ }|*2
  3444. {1:~ }{s: define }{1: }|
  3445. {1:~ }{n: jump }{1: }|
  3446. {1:~ }{n: list }{1: }|
  3447. {4: }{n: place }{4: }|
  3448. {6:fail} {n: undefine } |
  3449. {6:error}{n: unplace } |
  3450. :sign define^ |
  3451. ]],
  3452. }
  3453. feed('d')
  3454. screen:expect {
  3455. grid = [[
  3456. |
  3457. {1:~ }|*5
  3458. {4: }|
  3459. {6:fail} |
  3460. {6:error} |
  3461. :sign defined^ |
  3462. ]],
  3463. }
  3464. end)
  3465. it('wildoptions=pum and wildmode=longest,full #11622', function()
  3466. screen:try_resize(30, 8)
  3467. command('set wildmenu')
  3468. command('set wildoptions=pum')
  3469. command('set wildmode=longest,full')
  3470. -- With 'wildmode' set to 'longest,full', completing a match should display
  3471. -- the longest match, the wildmenu should not be displayed.
  3472. feed(':sign u<Tab>')
  3473. screen:expect {
  3474. grid = [[
  3475. |
  3476. {1:~ }|*6
  3477. :sign un^ |
  3478. ]],
  3479. }
  3480. eq(0, fn.wildmenumode())
  3481. -- pressing <Tab> should display the wildmenu
  3482. feed('<Tab>')
  3483. screen:expect {
  3484. grid = [[
  3485. |
  3486. {1:~ }|*4
  3487. {1:~ }{s: undefine }{1: }|
  3488. {1:~ }{n: unplace }{1: }|
  3489. :sign undefine^ |
  3490. ]],
  3491. }
  3492. eq(1, fn.wildmenumode())
  3493. -- pressing <Tab> second time should select the next entry in the menu
  3494. feed('<Tab>')
  3495. screen:expect {
  3496. grid = [[
  3497. |
  3498. {1:~ }|*4
  3499. {1:~ }{n: undefine }{1: }|
  3500. {1:~ }{s: unplace }{1: }|
  3501. :sign unplace^ |
  3502. ]],
  3503. }
  3504. end)
  3505. it('wildoptions=pum with a wrapped line in buffer vim-patch:8.2.4655', function()
  3506. screen:try_resize(32, 10)
  3507. api.nvim_buf_set_lines(0, 0, -1, true, { ('a'):rep(100) })
  3508. command('set wildoptions+=pum')
  3509. feed('$')
  3510. feed(':sign <Tab>')
  3511. screen:expect([[
  3512. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*3
  3513. aaaa {s: define } |
  3514. {1:~ }{n: jump }{1: }|
  3515. {1:~ }{n: list }{1: }|
  3516. {1:~ }{n: place }{1: }|
  3517. {1:~ }{n: undefine }{1: }|
  3518. {1:~ }{n: unplace }{1: }|
  3519. :sign define^ |
  3520. ]])
  3521. end)
  3522. -- oldtest: Test_wildmenu_pum_odd_wildchar()
  3523. it('wildoptions=pum with odd wildchar', function()
  3524. screen:try_resize(30, 10)
  3525. -- Test odd wildchar interactions with pum. Make sure they behave properly
  3526. -- and don't lead to memory corruption due to improperly cleaned up memory.
  3527. exec([[
  3528. set wildoptions=pum
  3529. set wildchar=<C-E>
  3530. ]])
  3531. feed(':sign <C-E>')
  3532. screen:expect([[
  3533. |
  3534. {1:~ }|*2
  3535. {1:~ }{s: define }{1: }|
  3536. {1:~ }{n: jump }{1: }|
  3537. {1:~ }{n: list }{1: }|
  3538. {1:~ }{n: place }{1: }|
  3539. {1:~ }{n: undefine }{1: }|
  3540. {1:~ }{n: unplace }{1: }|
  3541. :sign define^ |
  3542. ]])
  3543. -- <C-E> being a wildchar takes priority over its original functionality
  3544. feed('<C-E>')
  3545. screen:expect([[
  3546. |
  3547. {1:~ }|*2
  3548. {1:~ }{n: define }{1: }|
  3549. {1:~ }{s: jump }{1: }|
  3550. {1:~ }{n: list }{1: }|
  3551. {1:~ }{n: place }{1: }|
  3552. {1:~ }{n: undefine }{1: }|
  3553. {1:~ }{n: unplace }{1: }|
  3554. :sign jump^ |
  3555. ]])
  3556. feed('<Esc>')
  3557. screen:expect([[
  3558. ^ |
  3559. {1:~ }|*8
  3560. |
  3561. ]])
  3562. -- Escape key can be wildchar too. Double-<Esc> is hard-coded to escape
  3563. -- command-line, and we need to make sure to clean up properly.
  3564. command('set wildchar=<Esc>')
  3565. feed(':sign <Esc>')
  3566. screen:expect([[
  3567. |
  3568. {1:~ }|*2
  3569. {1:~ }{s: define }{1: }|
  3570. {1:~ }{n: jump }{1: }|
  3571. {1:~ }{n: list }{1: }|
  3572. {1:~ }{n: place }{1: }|
  3573. {1:~ }{n: undefine }{1: }|
  3574. {1:~ }{n: unplace }{1: }|
  3575. :sign define^ |
  3576. ]])
  3577. feed('<Esc>')
  3578. screen:expect([[
  3579. ^ |
  3580. {1:~ }|*8
  3581. |
  3582. ]])
  3583. -- <C-\> can also be wildchar. <C-\><C-N> however will still escape cmdline
  3584. -- and we again need to make sure we clean up properly.
  3585. command([[set wildchar=<C-\>]])
  3586. feed([[:sign <C-\><C-\>]])
  3587. screen:expect([[
  3588. |
  3589. {1:~ }|*2
  3590. {1:~ }{s: define }{1: }|
  3591. {1:~ }{n: jump }{1: }|
  3592. {1:~ }{n: list }{1: }|
  3593. {1:~ }{n: place }{1: }|
  3594. {1:~ }{n: undefine }{1: }|
  3595. {1:~ }{n: unplace }{1: }|
  3596. :sign define^ |
  3597. ]])
  3598. feed('<C-N>')
  3599. screen:expect([[
  3600. ^ |
  3601. {1:~ }|*8
  3602. |
  3603. ]])
  3604. end)
  3605. -- oldtest: Test_wildmenu_pum_hl_match()
  3606. it('highlighting matched text in cmdline pum', function()
  3607. exec([[
  3608. set wildoptions=pum,fuzzy
  3609. hi PmenuMatchSel guifg=Blue guibg=Grey
  3610. hi PmenuMatch guifg=Blue guibg=Plum1
  3611. ]])
  3612. feed(':sign plc<Tab>')
  3613. screen:expect([[
  3614. |
  3615. {1:~ }|*16
  3616. {1:~ }{s: }{ms:pl}{s:a}{ms:c}{s:e }{1: }|
  3617. {1:~ }{n: un}{mn:pl}{n:a}{mn:c}{n:e }{1: }|
  3618. :sign place^ |
  3619. ]])
  3620. feed('<Tab>')
  3621. screen:expect([[
  3622. |
  3623. {1:~ }|*16
  3624. {1:~ }{n: }{mn:pl}{n:a}{mn:c}{n:e }{1: }|
  3625. {1:~ }{s: un}{ms:pl}{s:a}{ms:c}{s:e }{1: }|
  3626. :sign unplace^ |
  3627. ]])
  3628. feed('<Tab>')
  3629. screen:expect([[
  3630. |
  3631. {1:~ }|*16
  3632. {1:~ }{n: }{mn:pl}{n:a}{mn:c}{n:e }{1: }|
  3633. {1:~ }{n: un}{mn:pl}{n:a}{mn:c}{n:e }{1: }|
  3634. :sign plc^ |
  3635. ]])
  3636. feed('<Esc>')
  3637. command('set wildoptions-=fuzzy')
  3638. feed(':sign un<Tab>')
  3639. screen:expect([[
  3640. |
  3641. {1:~ }|*16
  3642. {1:~ }{s: }{ms:un}{s:define }{1: }|
  3643. {1:~ }{n: }{mn:un}{n:place }{1: }|
  3644. :sign undefine^ |
  3645. ]])
  3646. feed('<Tab>')
  3647. screen:expect([[
  3648. |
  3649. {1:~ }|*16
  3650. {1:~ }{n: }{mn:un}{n:define }{1: }|
  3651. {1:~ }{s: }{ms:un}{s:place }{1: }|
  3652. :sign unplace^ |
  3653. ]])
  3654. feed('<Tab>')
  3655. screen:expect([[
  3656. |
  3657. {1:~ }|*16
  3658. {1:~ }{n: }{mn:un}{n:define }{1: }|
  3659. {1:~ }{n: }{mn:un}{n:place }{1: }|
  3660. :sign un^ |
  3661. ]])
  3662. end)
  3663. it(
  3664. 'cascading highlights for matched text (PmenuMatch, PmenuMatchSel) in cmdline pum',
  3665. function()
  3666. screen:add_extra_attr_ids {
  3667. [100] = {
  3668. background = Screen.colors.Grey,
  3669. italic = true,
  3670. underline = true,
  3671. foreground = Screen.colors.White,
  3672. },
  3673. [101] = {
  3674. strikethrough = true,
  3675. foreground = Screen.colors.Grey0,
  3676. italic = true,
  3677. bold = true,
  3678. underline = true,
  3679. background = Screen.colors.White,
  3680. },
  3681. [102] = {
  3682. strikethrough = true,
  3683. foreground = Screen.colors.Red,
  3684. italic = true,
  3685. underline = true,
  3686. background = Screen.colors.Grey,
  3687. },
  3688. [103] = {
  3689. foreground = Screen.colors.Yellow,
  3690. italic = true,
  3691. bold = true,
  3692. underline = true,
  3693. background = Screen.colors.Pink,
  3694. },
  3695. }
  3696. exec([[
  3697. set wildoptions=pum,fuzzy
  3698. hi Pmenu guifg=White guibg=Grey gui=underline,italic
  3699. hi PmenuSel guifg=Red gui=strikethrough
  3700. hi PmenuMatch guifg=Yellow guibg=Pink gui=bold
  3701. hi PmenuMatchSel guifg=Black guibg=White
  3702. ]])
  3703. feed(':sign plc<Tab>')
  3704. screen:expect([[
  3705. |
  3706. {1:~ }|*16
  3707. {1:~ }{102: }{101:pl}{102:a}{101:c}{102:e }{1: }|
  3708. {1:~ }{100: un}{103:pl}{100:a}{103:c}{100:e }{1: }|
  3709. :sign place^ |
  3710. ]])
  3711. end
  3712. )
  3713. end
  3714. it("'pumheight'", function()
  3715. screen:try_resize(32, 8)
  3716. feed('isome long prefix before the ')
  3717. command('set completeopt+=noinsert,noselect')
  3718. command('set linebreak')
  3719. command('set pumheight=2')
  3720. fn.complete(29, { 'word', 'choice', 'text', 'thing' })
  3721. if multigrid then
  3722. screen:expect {
  3723. grid = [[
  3724. ## grid 1
  3725. [2:--------------------------------]|*7
  3726. [3:--------------------------------]|
  3727. ## grid 2
  3728. some long prefix before the ^ |
  3729. {1:~ }|*6
  3730. ## grid 3
  3731. {2:-- INSERT --} |
  3732. ## grid 4
  3733. {n: word }{c: }|
  3734. {n: choice}{s: }|
  3735. ]],
  3736. float_pos = {
  3737. [4] = { -1, 'NW', 2, 1, 24, false, 100 },
  3738. },
  3739. }
  3740. else
  3741. screen:expect([[
  3742. some long prefix before the ^ |
  3743. {1:~ }{n: word }{c: }|
  3744. {1:~ }{n: choice}{s: }|
  3745. {1:~ }|*4
  3746. {2:-- INSERT --} |
  3747. ]])
  3748. end
  3749. end)
  3750. it("'pumwidth'", function()
  3751. screen:try_resize(32, 8)
  3752. feed('isome long prefix before the ')
  3753. command('set completeopt+=noinsert,noselect')
  3754. command('set linebreak')
  3755. command('set pumwidth=8')
  3756. fn.complete(29, { 'word', 'choice', 'text', 'thing' })
  3757. if multigrid then
  3758. screen:expect {
  3759. grid = [[
  3760. ## grid 1
  3761. [2:--------------------------------]|*7
  3762. [3:--------------------------------]|
  3763. ## grid 2
  3764. some long prefix before the ^ |
  3765. {1:~ }|*6
  3766. ## grid 3
  3767. {2:-- INSERT --} |
  3768. ## grid 4
  3769. {n: word }|
  3770. {n: choice}|
  3771. {n: text }|
  3772. {n: thing }|
  3773. ]],
  3774. float_pos = {
  3775. [4] = { -1, 'NW', 2, 1, 25, false, 100 },
  3776. },
  3777. }
  3778. else
  3779. screen:expect([[
  3780. some long prefix before the ^ |
  3781. {1:~ }{n: word }|
  3782. {1:~ }{n: choice}|
  3783. {1:~ }{n: text }|
  3784. {1:~ }{n: thing }|
  3785. {1:~ }|*2
  3786. {2:-- INSERT --} |
  3787. ]])
  3788. end
  3789. end)
  3790. it('does not crash when displayed in the last column with rightleft #12032', function()
  3791. local col = 30
  3792. local items = { 'word', 'choice', 'text', 'thing' }
  3793. local max_len = 0
  3794. for _, v in ipairs(items) do
  3795. max_len = max_len < #v and #v or max_len
  3796. end
  3797. screen:try_resize(col, 8)
  3798. command('set rightleft')
  3799. command('call setline(1, repeat(" ", &columns - ' .. max_len .. '))')
  3800. feed('$i')
  3801. fn.complete(col - max_len, items)
  3802. feed('<c-y>')
  3803. assert_alive()
  3804. end)
  3805. it('truncates double-width character correctly without scrollbar', function()
  3806. screen:try_resize(32, 8)
  3807. command('set completeopt+=menuone,noselect')
  3808. feed('i' .. string.rep(' ', 13))
  3809. fn.complete(14, { '哦哦哦哦哦哦哦哦哦哦' })
  3810. if multigrid then
  3811. screen:expect({
  3812. grid = [[
  3813. ## grid 1
  3814. [2:--------------------------------]|*7
  3815. [3:--------------------------------]|
  3816. ## grid 2
  3817. ^ |
  3818. {1:~ }|*6
  3819. ## grid 3
  3820. {2:-- INSERT --} |
  3821. ## grid 4
  3822. {n: 哦哦哦哦哦哦哦哦哦>}|
  3823. ]],
  3824. float_pos = { [4] = { -1, 'NW', 2, 1, 12, false, 100 } },
  3825. })
  3826. else
  3827. screen:expect([[
  3828. ^ |
  3829. {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}|
  3830. {1:~ }|*5
  3831. {2:-- INSERT --} |
  3832. ]])
  3833. end
  3834. end)
  3835. it('truncates double-width character correctly with scrollbar', function()
  3836. screen:try_resize(32, 8)
  3837. command('set completeopt+=noselect')
  3838. command('set pumheight=4')
  3839. feed('i' .. string.rep(' ', 12))
  3840. local items = {}
  3841. for _ = 1, 8 do
  3842. table.insert(items, { word = '哦哦哦哦哦哦哦哦哦哦', equal = 1, dup = 1 })
  3843. end
  3844. fn.complete(13, items)
  3845. if multigrid then
  3846. screen:expect({
  3847. grid = [[
  3848. ## grid 1
  3849. [2:--------------------------------]|*7
  3850. [3:--------------------------------]|
  3851. ## grid 2
  3852. ^ |
  3853. {1:~ }|*6
  3854. ## grid 3
  3855. {2:-- INSERT --} |
  3856. ## grid 4
  3857. {n: 哦哦哦哦哦哦哦哦哦>}{c: }|*2
  3858. {n: 哦哦哦哦哦哦哦哦哦>}{s: }|*2
  3859. ]],
  3860. float_pos = { [4] = { -1, 'NW', 2, 1, 11, false, 100 } },
  3861. })
  3862. else
  3863. screen:expect([[
  3864. ^ |
  3865. {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{c: }|*2
  3866. {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{s: }|*2
  3867. {1:~ }|*2
  3868. {2:-- INSERT --} |
  3869. ]])
  3870. end
  3871. end)
  3872. it('supports mousemodel=popup', function()
  3873. screen:try_resize(32, 6)
  3874. exec([[
  3875. call setline(1, 'popup menu test')
  3876. set mouse=a mousemodel=popup
  3877. " Delete the default MenuPopup event handler.
  3878. autocmd! nvim.popupmenu
  3879. aunmenu PopUp
  3880. menu PopUp.foo :let g:menustr = 'foo'<CR>
  3881. menu PopUp.bar :let g:menustr = 'bar'<CR>
  3882. menu PopUp.baz :let g:menustr = 'baz'<CR>
  3883. ]])
  3884. if multigrid then
  3885. api.nvim_input_mouse('right', 'press', '', 2, 0, 4)
  3886. screen:expect({
  3887. grid = [[
  3888. ## grid 1
  3889. [2:--------------------------------]|*5
  3890. [3:--------------------------------]|
  3891. ## grid 2
  3892. ^popup menu test |
  3893. {1:~ }|*4
  3894. ## grid 3
  3895. |
  3896. ## grid 4
  3897. {n: foo }|
  3898. {n: bar }|
  3899. {n: baz }|
  3900. ]],
  3901. float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
  3902. })
  3903. else
  3904. feed('<RightMouse><4,0>')
  3905. screen:expect([[
  3906. ^popup menu test |
  3907. {1:~ }{n: foo }{1: }|
  3908. {1:~ }{n: bar }{1: }|
  3909. {1:~ }{n: baz }{1: }|
  3910. {1:~ }|
  3911. |
  3912. ]])
  3913. end
  3914. feed('<Down>')
  3915. if multigrid then
  3916. screen:expect({
  3917. grid = [[
  3918. ## grid 1
  3919. [2:--------------------------------]|*5
  3920. [3:--------------------------------]|
  3921. ## grid 2
  3922. ^popup menu test |
  3923. {1:~ }|*4
  3924. ## grid 3
  3925. |
  3926. ## grid 4
  3927. {s: foo }|
  3928. {n: bar }|
  3929. {n: baz }|
  3930. ]],
  3931. float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
  3932. })
  3933. else
  3934. screen:expect([[
  3935. ^popup menu test |
  3936. {1:~ }{s: foo }{1: }|
  3937. {1:~ }{n: bar }{1: }|
  3938. {1:~ }{n: baz }{1: }|
  3939. {1:~ }|
  3940. |
  3941. ]])
  3942. end
  3943. feed('<Down>')
  3944. if multigrid then
  3945. screen:expect({
  3946. grid = [[
  3947. ## grid 1
  3948. [2:--------------------------------]|*5
  3949. [3:--------------------------------]|
  3950. ## grid 2
  3951. ^popup menu test |
  3952. {1:~ }|*4
  3953. ## grid 3
  3954. |
  3955. ## grid 4
  3956. {n: foo }|
  3957. {s: bar }|
  3958. {n: baz }|
  3959. ]],
  3960. float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
  3961. })
  3962. else
  3963. screen:expect([[
  3964. ^popup menu test |
  3965. {1:~ }{n: foo }{1: }|
  3966. {1:~ }{s: bar }{1: }|
  3967. {1:~ }{n: baz }{1: }|
  3968. {1:~ }|
  3969. |
  3970. ]])
  3971. end
  3972. feed('<CR>')
  3973. if multigrid then
  3974. screen:expect({
  3975. grid = [[
  3976. ## grid 1
  3977. [2:--------------------------------]|*5
  3978. [3:--------------------------------]|
  3979. ## grid 2
  3980. ^popup menu test |
  3981. {1:~ }|*4
  3982. ## grid 3
  3983. :let g:menustr = 'bar' |
  3984. ]],
  3985. })
  3986. else
  3987. screen:expect([[
  3988. ^popup menu test |
  3989. {1:~ }|*4
  3990. :let g:menustr = 'bar' |
  3991. ]])
  3992. end
  3993. eq('bar', api.nvim_get_var('menustr'))
  3994. if multigrid then
  3995. api.nvim_input_mouse('right', 'press', '', 2, 2, 20)
  3996. screen:expect({
  3997. grid = [[
  3998. ## grid 1
  3999. [2:--------------------------------]|*5
  4000. [3:--------------------------------]|
  4001. ## grid 2
  4002. ^popup menu test |
  4003. {1:~ }|*4
  4004. ## grid 3
  4005. :let g:menustr = 'bar' |
  4006. ## grid 4
  4007. {n: foo }|
  4008. {n: bar }|
  4009. {n: baz }|
  4010. ]],
  4011. float_pos = { [4] = { -1, 'NW', 2, 3, 19, false, 250 } },
  4012. })
  4013. else
  4014. feed('<RightMouse><20,2>')
  4015. screen:expect([[
  4016. ^popup menu test |
  4017. {1:~ }|*2
  4018. {1:~ }{n: foo }{1: }|
  4019. {1:~ }{n: bar }{1: }|
  4020. :let g:menustr = 'b{n: baz } |
  4021. ]])
  4022. end
  4023. if multigrid then
  4024. api.nvim_input_mouse('right', 'press', '', 2, 0, 18)
  4025. screen:expect {
  4026. grid = [[
  4027. ## grid 1
  4028. [2:--------------------------------]|*5
  4029. [3:--------------------------------]|
  4030. ## grid 2
  4031. ^popup menu test |
  4032. {1:~ }|*4
  4033. ## grid 3
  4034. :let g:menustr = 'bar' |
  4035. ## grid 4
  4036. {n: foo }|
  4037. {n: bar }|
  4038. {n: baz }|
  4039. ]],
  4040. float_pos = { [4] = { -1, 'NW', 2, 1, 17, false, 250 } },
  4041. }
  4042. else
  4043. feed('<RightMouse><18,0>')
  4044. screen:expect([[
  4045. ^popup menu test |
  4046. {1:~ }{n: foo }{1: }|
  4047. {1:~ }{n: bar }{1: }|
  4048. {1:~ }{n: baz }{1: }|
  4049. {1:~ }|
  4050. :let g:menustr = 'bar' |
  4051. ]])
  4052. end
  4053. if multigrid then
  4054. api.nvim_input_mouse('right', 'press', '', 4, 1, 3)
  4055. screen:expect({
  4056. grid = [[
  4057. ## grid 1
  4058. [2:--------------------------------]|*5
  4059. [3:--------------------------------]|
  4060. ## grid 2
  4061. ^popup menu test |
  4062. {1:~ }|*4
  4063. ## grid 3
  4064. :let g:menustr = 'bar' |
  4065. ## grid 4
  4066. {n: foo }|
  4067. {n: bar }|
  4068. {n: baz }|
  4069. ]],
  4070. float_pos = { [4] = { -1, 'NW', 2, 3, 19, false, 250 } },
  4071. })
  4072. else
  4073. feed('<RightMouse><20,2>')
  4074. screen:expect([[
  4075. ^popup menu test |
  4076. {1:~ }|*2
  4077. {1:~ }{n: foo }{1: }|
  4078. {1:~ }{n: bar }{1: }|
  4079. :let g:menustr = 'b{n: baz } |
  4080. ]])
  4081. end
  4082. if multigrid then
  4083. api.nvim_input_mouse('left', 'press', '', 4, 2, 2)
  4084. screen:expect({
  4085. grid = [[
  4086. ## grid 1
  4087. [2:--------------------------------]|*5
  4088. [3:--------------------------------]|
  4089. ## grid 2
  4090. ^popup menu test |
  4091. {1:~ }|*4
  4092. ## grid 3
  4093. :let g:menustr = 'baz' |
  4094. ]],
  4095. })
  4096. else
  4097. feed('<LeftMouse><21,5>')
  4098. screen:expect([[
  4099. ^popup menu test |
  4100. {1:~ }|*4
  4101. :let g:menustr = 'baz' |
  4102. ]])
  4103. end
  4104. eq('baz', api.nvim_get_var('menustr'))
  4105. if multigrid then
  4106. api.nvim_input_mouse('right', 'press', '', 2, 0, 4)
  4107. screen:expect({
  4108. grid = [[
  4109. ## grid 1
  4110. [2:--------------------------------]|*5
  4111. [3:--------------------------------]|
  4112. ## grid 2
  4113. ^popup menu test |
  4114. {1:~ }|*4
  4115. ## grid 3
  4116. :let g:menustr = 'baz' |
  4117. ## grid 4
  4118. {n: foo }|
  4119. {n: bar }|
  4120. {n: baz }|
  4121. ]],
  4122. float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
  4123. })
  4124. else
  4125. feed('<RightMouse><4,0>')
  4126. screen:expect([[
  4127. ^popup menu test |
  4128. {1:~ }{n: foo }{1: }|
  4129. {1:~ }{n: bar }{1: }|
  4130. {1:~ }{n: baz }{1: }|
  4131. {1:~ }|
  4132. :let g:menustr = 'baz' |
  4133. ]])
  4134. end
  4135. if multigrid then
  4136. api.nvim_input_mouse('right', 'drag', '', 2, 3, 6)
  4137. screen:expect({
  4138. grid = [[
  4139. ## grid 1
  4140. [2:--------------------------------]|*5
  4141. [3:--------------------------------]|
  4142. ## grid 2
  4143. ^popup menu test |
  4144. {1:~ }|*4
  4145. ## grid 3
  4146. :let g:menustr = 'baz' |
  4147. ## grid 4
  4148. {n: foo }|
  4149. {n: bar }|
  4150. {s: baz }|
  4151. ]],
  4152. float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
  4153. })
  4154. else
  4155. feed('<RightDrag><6,3>')
  4156. screen:expect([[
  4157. ^popup menu test |
  4158. {1:~ }{n: foo }{1: }|
  4159. {1:~ }{n: bar }{1: }|
  4160. {1:~ }{s: baz }{1: }|
  4161. {1:~ }|
  4162. :let g:menustr = 'baz' |
  4163. ]])
  4164. end
  4165. if multigrid then
  4166. api.nvim_input_mouse('right', 'release', '', 2, 1, 6)
  4167. screen:expect({
  4168. grid = [[
  4169. ## grid 1
  4170. [2:--------------------------------]|*5
  4171. [3:--------------------------------]|
  4172. ## grid 2
  4173. ^popup menu test |
  4174. {1:~ }|*4
  4175. ## grid 3
  4176. :let g:menustr = 'foo' |
  4177. ]],
  4178. })
  4179. else
  4180. feed('<RightRelease><6,1>')
  4181. screen:expect([[
  4182. ^popup menu test |
  4183. {1:~ }|*4
  4184. :let g:menustr = 'foo' |
  4185. ]])
  4186. end
  4187. eq('foo', api.nvim_get_var('menustr'))
  4188. eq(false, screen.options.mousemoveevent)
  4189. if multigrid then
  4190. api.nvim_input_mouse('right', 'press', '', 2, 0, 4)
  4191. screen:expect({
  4192. grid = [[
  4193. ## grid 1
  4194. [2:--------------------------------]|*5
  4195. [3:--------------------------------]|
  4196. ## grid 2
  4197. ^popup menu test |
  4198. {1:~ }|*4
  4199. ## grid 3
  4200. :let g:menustr = 'foo' |
  4201. ## grid 4
  4202. {n: foo }|
  4203. {n: bar }|
  4204. {n: baz }|
  4205. ]],
  4206. float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
  4207. })
  4208. else
  4209. feed('<RightMouse><4,0>')
  4210. screen:expect([[
  4211. ^popup menu test |
  4212. {1:~ }{n: foo }{1: }|
  4213. {1:~ }{n: bar }{1: }|
  4214. {1:~ }{n: baz }{1: }|
  4215. {1:~ }|
  4216. :let g:menustr = 'foo' |
  4217. ]])
  4218. end
  4219. eq(true, screen.options.mousemoveevent)
  4220. if multigrid then
  4221. api.nvim_input_mouse('wheel', 'up', '', 2, 0, 4)
  4222. screen:expect({
  4223. grid = [[
  4224. ## grid 1
  4225. [2:--------------------------------]|*5
  4226. [3:--------------------------------]|
  4227. ## grid 2
  4228. ^popup menu test |
  4229. {1:~ }|*4
  4230. ## grid 3
  4231. :let g:menustr = 'foo' |
  4232. ## grid 4
  4233. {s: foo }|
  4234. {n: bar }|
  4235. {n: baz }|
  4236. ]],
  4237. float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
  4238. })
  4239. else
  4240. feed('<ScrollWheelUp><4,0>')
  4241. screen:expect([[
  4242. ^popup menu test |
  4243. {1:~ }{s: foo }{1: }|
  4244. {1:~ }{n: bar }{1: }|
  4245. {1:~ }{n: baz }{1: }|
  4246. {1:~ }|
  4247. :let g:menustr = 'foo' |
  4248. ]])
  4249. end
  4250. eq(true, screen.options.mousemoveevent)
  4251. if multigrid then
  4252. api.nvim_input_mouse('move', '', '', 4, 2, 3)
  4253. screen:expect({
  4254. grid = [[
  4255. ## grid 1
  4256. [2:--------------------------------]|*5
  4257. [3:--------------------------------]|
  4258. ## grid 2
  4259. ^popup menu test |
  4260. {1:~ }|*4
  4261. ## grid 3
  4262. :let g:menustr = 'foo' |
  4263. ## grid 4
  4264. {n: foo }|
  4265. {n: bar }|
  4266. {s: baz }|
  4267. ]],
  4268. float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
  4269. })
  4270. else
  4271. feed('<MouseMove><6,3>')
  4272. screen:expect([[
  4273. ^popup menu test |
  4274. {1:~ }{n: foo }{1: }|
  4275. {1:~ }{n: bar }{1: }|
  4276. {1:~ }{s: baz }{1: }|
  4277. {1:~ }|
  4278. :let g:menustr = 'foo' |
  4279. ]])
  4280. end
  4281. eq(true, screen.options.mousemoveevent)
  4282. if multigrid then
  4283. api.nvim_input_mouse('wheel', 'down', '', 4, 2, 3)
  4284. screen:expect({
  4285. grid = [[
  4286. ## grid 1
  4287. [2:--------------------------------]|*5
  4288. [3:--------------------------------]|
  4289. ## grid 2
  4290. ^popup menu test |
  4291. {1:~ }|*4
  4292. ## grid 3
  4293. :let g:menustr = 'foo' |
  4294. ## grid 4
  4295. {n: foo }|
  4296. {s: bar }|
  4297. {n: baz }|
  4298. ]],
  4299. float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
  4300. })
  4301. else
  4302. feed('<ScrollWheelDown><6,3>')
  4303. screen:expect([[
  4304. ^popup menu test |
  4305. {1:~ }{n: foo }{1: }|
  4306. {1:~ }{s: bar }{1: }|
  4307. {1:~ }{n: baz }{1: }|
  4308. {1:~ }|
  4309. :let g:menustr = 'foo' |
  4310. ]])
  4311. end
  4312. eq(true, screen.options.mousemoveevent)
  4313. if multigrid then
  4314. api.nvim_input_mouse('left', 'press', '', 4, 1, 3)
  4315. screen:expect({
  4316. grid = [[
  4317. ## grid 1
  4318. [2:--------------------------------]|*5
  4319. [3:--------------------------------]|
  4320. ## grid 2
  4321. ^popup menu test |
  4322. {1:~ }|*4
  4323. ## grid 3
  4324. :let g:menustr = 'bar' |
  4325. ]],
  4326. })
  4327. else
  4328. feed('<LeftMouse><6,2>')
  4329. screen:expect([[
  4330. ^popup menu test |
  4331. {1:~ }|*4
  4332. :let g:menustr = 'bar' |
  4333. ]])
  4334. end
  4335. eq(false, screen.options.mousemoveevent)
  4336. eq('bar', api.nvim_get_var('menustr'))
  4337. command('set laststatus=0 | botright split')
  4338. if multigrid then
  4339. api.nvim_input_mouse('right', 'press', '', 5, 1, 20)
  4340. screen:expect({
  4341. grid = [[
  4342. ## grid 1
  4343. [2:--------------------------------]|*2
  4344. {3:[No Name] [+] }|
  4345. [5:--------------------------------]|*2
  4346. [3:--------------------------------]|
  4347. ## grid 2
  4348. popup menu test |
  4349. {1:~ }|
  4350. ## grid 3
  4351. :let g:menustr = 'bar' |
  4352. ## grid 4
  4353. {n: foo }|
  4354. {n: bar }|
  4355. {n: baz }|
  4356. ## grid 5
  4357. ^popup menu test |
  4358. {1:~ }|
  4359. ]],
  4360. float_pos = { [4] = { -1, 'SW', 5, 1, 19, false, 250 } },
  4361. })
  4362. else
  4363. feed('<RightMouse><20,4>')
  4364. screen:expect([[
  4365. popup menu test |
  4366. {1:~ }{n: foo }{1: }|
  4367. {3:[No Name] [+] }{n: bar }{3: }|
  4368. ^popup menu test {n: baz } |
  4369. {1:~ }|
  4370. :let g:menustr = 'bar' |
  4371. ]])
  4372. end
  4373. if multigrid then
  4374. api.nvim_input_mouse('left', 'press', '', 4, 2, 2)
  4375. screen:expect({
  4376. grid = [[
  4377. ## grid 1
  4378. [2:--------------------------------]|*2
  4379. {3:[No Name] [+] }|
  4380. [5:--------------------------------]|*2
  4381. [3:--------------------------------]|
  4382. ## grid 2
  4383. popup menu test |
  4384. {1:~ }|
  4385. ## grid 3
  4386. :let g:menustr = 'baz' |
  4387. ## grid 5
  4388. ^popup menu test |
  4389. {1:~ }|
  4390. ]],
  4391. })
  4392. else
  4393. feed('<LeftMouse><21,3>')
  4394. screen:expect([[
  4395. popup menu test |
  4396. {1:~ }|
  4397. {3:[No Name] [+] }|
  4398. ^popup menu test |
  4399. {1:~ }|
  4400. :let g:menustr = 'baz' |
  4401. ]])
  4402. end
  4403. eq('baz', api.nvim_get_var('menustr'))
  4404. command('set winwidth=1 | rightbelow vsplit')
  4405. if multigrid then
  4406. api.nvim_input_mouse('right', 'press', '', 6, 1, 14)
  4407. screen:expect({
  4408. grid = [[
  4409. ## grid 1
  4410. [2:--------------------------------]|*2
  4411. {3:[No Name] [+] }|
  4412. [5:---------------]│[6:----------------]|*2
  4413. [3:--------------------------------]|
  4414. ## grid 2
  4415. popup menu test |
  4416. {1:~ }|
  4417. ## grid 3
  4418. :let g:menustr = 'baz' |
  4419. ## grid 4
  4420. {n: foo}|
  4421. {n: bar}|
  4422. {n: baz}|
  4423. ## grid 5
  4424. popup menu test|
  4425. {1:~ }|
  4426. ## grid 6
  4427. ^popup menu test |
  4428. {1:~ }|
  4429. ]],
  4430. float_pos = { [4] = { -1, 'SW', 6, 1, 12, false, 250 } },
  4431. })
  4432. else
  4433. feed('<RightMouse><30,4>')
  4434. screen:expect([[
  4435. popup menu test |
  4436. {1:~ }{n: foo}|
  4437. {3:[No Name] [+] }{n: bar}|
  4438. popup menu test│^popup menu t{n: baz}|
  4439. {1:~ }│{1:~ }|
  4440. :let g:menustr = 'baz' |
  4441. ]])
  4442. end
  4443. if multigrid then
  4444. api.nvim_input_mouse('left', 'press', '', 4, 0, 2)
  4445. screen:expect({
  4446. grid = [[
  4447. ## grid 1
  4448. [2:--------------------------------]|*2
  4449. {3:[No Name] [+] }|
  4450. [5:---------------]│[6:----------------]|*2
  4451. [3:--------------------------------]|
  4452. ## grid 2
  4453. popup menu test |
  4454. {1:~ }|
  4455. ## grid 3
  4456. :let g:menustr = 'foo' |
  4457. ## grid 5
  4458. popup menu test|
  4459. {1:~ }|
  4460. ## grid 6
  4461. ^popup menu test |
  4462. {1:~ }|
  4463. ]],
  4464. })
  4465. else
  4466. feed('<LeftMouse><31,1>')
  4467. screen:expect([[
  4468. popup menu test |
  4469. {1:~ }|
  4470. {3:[No Name] [+] }|
  4471. popup menu test│^popup menu test |
  4472. {1:~ }│{1:~ }|
  4473. :let g:menustr = 'foo' |
  4474. ]])
  4475. end
  4476. eq('foo', api.nvim_get_var('menustr'))
  4477. command('setlocal winbar=WINBAR')
  4478. if multigrid then
  4479. api.nvim_input_mouse('right', 'press', '', 6, 1, 14)
  4480. screen:expect({
  4481. grid = [[
  4482. ## grid 1
  4483. [2:--------------------------------]|*2
  4484. {3:[No Name] [+] }|
  4485. [5:---------------]│[6:----------------]|*2
  4486. [3:--------------------------------]|
  4487. ## grid 2
  4488. popup menu test |
  4489. {1:~ }|
  4490. ## grid 3
  4491. :let g:menustr = 'foo' |
  4492. ## grid 4
  4493. {n: foo}|
  4494. {n: bar}|
  4495. {n: baz}|
  4496. ## grid 5
  4497. popup menu test|
  4498. {1:~ }|
  4499. ## grid 6
  4500. {2:WINBAR }|
  4501. ^popup menu test |
  4502. ]],
  4503. float_pos = { [4] = { -1, 'SW', 6, 1, 12, false, 250 } },
  4504. })
  4505. else
  4506. feed('<RightMouse><30,4>')
  4507. screen:expect([[
  4508. popup menu test |
  4509. {1:~ }{n: foo}|
  4510. {3:[No Name] [+] }{n: bar}|
  4511. popup menu test│{2:WINBAR }{n: baz}|
  4512. {1:~ }│^popup menu test |
  4513. :let g:menustr = 'foo' |
  4514. ]])
  4515. end
  4516. local no_menu_screen ---@type string|test.function.ui.screen.Expect
  4517. if multigrid then
  4518. api.nvim_input_mouse('left', 'press', '', 4, 1, 2)
  4519. no_menu_screen = {
  4520. grid = [[
  4521. ## grid 1
  4522. [2:--------------------------------]|*2
  4523. {3:[No Name] [+] }|
  4524. [5:---------------]│[6:----------------]|*2
  4525. [3:--------------------------------]|
  4526. ## grid 2
  4527. popup menu test |
  4528. {1:~ }|
  4529. ## grid 3
  4530. :let g:menustr = 'bar' |
  4531. ## grid 5
  4532. popup menu test|
  4533. {1:~ }|
  4534. ## grid 6
  4535. {2:WINBAR }|
  4536. ^popup menu test |
  4537. ]],
  4538. }
  4539. else
  4540. feed('<LeftMouse><31,2>')
  4541. no_menu_screen = {
  4542. grid = [[
  4543. popup menu test |
  4544. {1:~ }|
  4545. {3:[No Name] [+] }|
  4546. popup menu test│{2:WINBAR }|
  4547. {1:~ }│^popup menu test |
  4548. :let g:menustr = 'bar' |
  4549. ]],
  4550. }
  4551. end
  4552. screen:expect(no_menu_screen)
  4553. eq('bar', api.nvim_get_var('menustr'))
  4554. local no_sel_screen ---@type string|test.function.ui.screen.Expect
  4555. if multigrid then
  4556. no_sel_screen = {
  4557. grid = [[
  4558. ## grid 1
  4559. [2:--------------------------------]|*2
  4560. {3:[No Name] [+] }|
  4561. [5:---------------]│[6:----------------]|*2
  4562. [3:--------------------------------]|
  4563. ## grid 2
  4564. popup menu test |
  4565. {1:~ }|
  4566. ## grid 3
  4567. :let g:menustr = 'bar' |
  4568. ## grid 4
  4569. {n: foo }|
  4570. {n: bar }|
  4571. {n: baz }|
  4572. ## grid 5
  4573. popup menu test|
  4574. {1:~ }|
  4575. ## grid 6
  4576. {2:WINBAR }|
  4577. ^popup menu test |
  4578. ]],
  4579. float_pos = { [4] = { -1, 'NW', 1, 1, 19, false, 250 } },
  4580. }
  4581. else
  4582. no_sel_screen = {
  4583. grid = [[
  4584. popup menu test |
  4585. {1:~ }{n: foo }{1: }|
  4586. {3:[No Name] [+] }{n: bar }{3: }|
  4587. popup menu test│{2:WIN}{n: baz }{2: }|
  4588. {1:~ }│^popup menu test |
  4589. :let g:menustr = 'bar' |
  4590. ]],
  4591. }
  4592. end
  4593. local sel_screens = {} ---@type (string|test.function.ui.screen.Expect)[]
  4594. for i, s in ipairs({ 'foo', 'bar', 'baz' }) do
  4595. local sel_screen = vim.deepcopy(no_sel_screen)
  4596. local grid = assert(sel_screen.grid)
  4597. grid = grid:gsub(vim.pesc(('{n: %s }'):format(s)), ('{s: %s }'):format(s))
  4598. sel_screen.grid = grid
  4599. sel_screens[i] = sel_screen
  4600. end
  4601. command([[let g:menustr = '']])
  4602. local g = multigrid and 1 or 0
  4603. api.nvim_input_mouse('right', 'press', '', g, 0, 20)
  4604. screen:expect(no_sel_screen)
  4605. api.nvim_input_mouse('move', '', '', g, 1, 19)
  4606. screen:expect(sel_screens[1])
  4607. api.nvim_input_mouse('move', '', '', g, 1, 18)
  4608. screen:expect(no_sel_screen)
  4609. api.nvim_input_mouse('move', '', '', g, 2, 23)
  4610. screen:expect(sel_screens[2])
  4611. api.nvim_input_mouse('move', '', '', g, 2, 24)
  4612. screen:expect(no_sel_screen)
  4613. api.nvim_input_mouse('move', '', '', g, 3, 19)
  4614. screen:expect(sel_screens[3])
  4615. api.nvim_input_mouse('left', 'press', '', g, 3, 18)
  4616. screen:expect(no_menu_screen)
  4617. eq('', api.nvim_get_var('menustr'))
  4618. command('wincmd t | set rightleft')
  4619. if multigrid then
  4620. no_menu_screen = {
  4621. grid = [[
  4622. ## grid 1
  4623. [2:--------------------------------]|*2
  4624. {4:[No Name] [+] }|
  4625. [5:---------------]│[6:----------------]|*2
  4626. [3:--------------------------------]|
  4627. ## grid 2
  4628. tset unem pupo^p|
  4629. {1: ~}|
  4630. ## grid 3
  4631. :let g:menustr = 'bar' |
  4632. ## grid 5
  4633. popup menu test|
  4634. {1:~ }|
  4635. ## grid 6
  4636. {2:WINBAR }|
  4637. popup menu test |
  4638. ]],
  4639. }
  4640. else
  4641. no_menu_screen = {
  4642. grid = [[
  4643. tset unem pupo^p|
  4644. {1: ~}|
  4645. {4:[No Name] [+] }|
  4646. popup menu test│{2:WINBAR }|
  4647. {1:~ }│popup menu test |
  4648. :let g:menustr = 'bar' |
  4649. ]],
  4650. }
  4651. end
  4652. screen:expect(no_menu_screen)
  4653. if multigrid then
  4654. no_sel_screen = {
  4655. grid = [[
  4656. ## grid 1
  4657. [2:--------------------------------]|*2
  4658. {4:[No Name] [+] }|
  4659. [5:---------------]│[6:----------------]|*2
  4660. [3:--------------------------------]|
  4661. ## grid 2
  4662. tset unem pupo^p|
  4663. {1: ~}|
  4664. ## grid 3
  4665. :let g:menustr = 'bar' |
  4666. ## grid 4
  4667. {n: oof }|
  4668. {n: rab }|
  4669. {n: zab }|
  4670. ## grid 5
  4671. popup menu test|
  4672. {1:~ }|
  4673. ## grid 6
  4674. {2:WINBAR }|
  4675. popup menu test |
  4676. ]],
  4677. float_pos = { [4] = { -1, 'NW', 1, 1, 17, false, 250 } },
  4678. }
  4679. else
  4680. no_sel_screen = {
  4681. grid = [[
  4682. tset unem pupo^p|
  4683. {1: }{n: oof }{1: ~}|
  4684. {4:[No Name] [+] }{n: rab }{4: }|
  4685. popup menu test│{2:W}{n: zab }{2: }|
  4686. {1:~ }│popup menu test |
  4687. :let g:menustr = 'bar' |
  4688. ]],
  4689. }
  4690. end
  4691. for i, s in ipairs({ 'oof', 'rab', 'zab' }) do
  4692. local sel_screen = vim.deepcopy(no_sel_screen)
  4693. local grid = assert(sel_screen.grid)
  4694. grid = grid:gsub(vim.pesc(('{n: %s }'):format(s)), ('{s: %s }'):format(s))
  4695. sel_screen.grid = grid
  4696. sel_screens[i] = sel_screen
  4697. end
  4698. api.nvim_input_mouse('right', 'press', '', g, 0, 20)
  4699. screen:expect(no_sel_screen)
  4700. api.nvim_input_mouse('move', '', '', g, 1, 21)
  4701. screen:expect(sel_screens[1])
  4702. api.nvim_input_mouse('move', '', '', g, 1, 22)
  4703. screen:expect(no_sel_screen)
  4704. api.nvim_input_mouse('move', '', '', g, 2, 17)
  4705. screen:expect(sel_screens[2])
  4706. api.nvim_input_mouse('move', '', '', g, 2, 16)
  4707. screen:expect(no_sel_screen)
  4708. api.nvim_input_mouse('move', '', '', g, 3, 21)
  4709. screen:expect(sel_screens[3])
  4710. api.nvim_input_mouse('left', 'press', '', g, 3, 22)
  4711. screen:expect(no_menu_screen)
  4712. eq('', api.nvim_get_var('menustr'))
  4713. command('set norightleft')
  4714. end)
  4715. if not multigrid then
  4716. -- oldtest: Test_popup_command_dump()
  4717. it(':popup command', function()
  4718. exec([[
  4719. " Delete the default MenuPopup event handler.
  4720. autocmd! nvim.popupmenu
  4721. func ChangeMenu()
  4722. aunmenu PopUp.&Paste
  4723. nnoremenu 1.40 PopUp.&Paste :echomsg "pasted"<CR>
  4724. echomsg 'changed'
  4725. return "\<Ignore>"
  4726. endfunc
  4727. let lines =<< trim END
  4728. one two three four five
  4729. and one two Xthree four five
  4730. one more two three four five
  4731. END
  4732. call setline(1, lines)
  4733. aunmenu *
  4734. source $VIMRUNTIME/menu.vim
  4735. ]])
  4736. feed('/X<CR>:popup PopUp<CR>')
  4737. screen:expect([[
  4738. one two three four five |
  4739. and one two {7:^X}three four five |
  4740. one more tw{n: Undo } |
  4741. {1:~ }{n: }{1: }|
  4742. {1:~ }{n: Paste }{1: }|
  4743. {1:~ }{n: }{1: }|
  4744. {1:~ }{n: Select Word }{1: }|
  4745. {1:~ }{n: Select Sentence }{1: }|
  4746. {1:~ }{n: Select Paragraph }{1: }|
  4747. {1:~ }{n: Select Line }{1: }|
  4748. {1:~ }{n: Select Block }{1: }|
  4749. {1:~ }{n: Select All }{1: }|
  4750. {1:~ }|*7
  4751. :popup PopUp |
  4752. ]])
  4753. -- go to the Paste entry in the menu
  4754. feed('jj')
  4755. screen:expect([[
  4756. one two three four five |
  4757. and one two {7:^X}three four five |
  4758. one more tw{n: Undo } |
  4759. {1:~ }{n: }{1: }|
  4760. {1:~ }{s: Paste }{1: }|
  4761. {1:~ }{n: }{1: }|
  4762. {1:~ }{n: Select Word }{1: }|
  4763. {1:~ }{n: Select Sentence }{1: }|
  4764. {1:~ }{n: Select Paragraph }{1: }|
  4765. {1:~ }{n: Select Line }{1: }|
  4766. {1:~ }{n: Select Block }{1: }|
  4767. {1:~ }{n: Select All }{1: }|
  4768. {1:~ }|*7
  4769. :popup PopUp |
  4770. ]])
  4771. -- Select a word
  4772. feed('j')
  4773. screen:expect([[
  4774. one two three four five |
  4775. and one two {7:^X}three four five |
  4776. one more tw{n: Undo } |
  4777. {1:~ }{n: }{1: }|
  4778. {1:~ }{n: Paste }{1: }|
  4779. {1:~ }{n: }{1: }|
  4780. {1:~ }{s: Select Word }{1: }|
  4781. {1:~ }{n: Select Sentence }{1: }|
  4782. {1:~ }{n: Select Paragraph }{1: }|
  4783. {1:~ }{n: Select Line }{1: }|
  4784. {1:~ }{n: Select Block }{1: }|
  4785. {1:~ }{n: Select All }{1: }|
  4786. {1:~ }|*7
  4787. :popup PopUp |
  4788. ]])
  4789. feed('<Esc>')
  4790. command('set rightleft')
  4791. feed('/X<CR>:popup PopUp<CR>')
  4792. screen:expect([[
  4793. evif ruof eerht owt eno|
  4794. evif ruof eerht{7:^X} owt eno dna|
  4795. {n: odnU }wt erom eno|
  4796. {1: }{n: }{1: ~}|
  4797. {1: }{n: etsaP }{1: ~}|
  4798. {1: }{n: }{1: ~}|
  4799. {1: }{n: droW tceleS }{1: ~}|
  4800. {1: }{n: ecnetneS tceleS }{1: ~}|
  4801. {1: }{n: hpargaraP tceleS }{1: ~}|
  4802. {1: }{n: eniL tceleS }{1: ~}|
  4803. {1: }{n: kcolB tceleS }{1: ~}|
  4804. {1: }{n: llA tceleS }{1: ~}|
  4805. {1: ~}|*7
  4806. :popup PopUp |
  4807. ]])
  4808. feed('<Esc>')
  4809. command('set norightleft')
  4810. -- Set an <expr> mapping to change a menu entry while it's displayed.
  4811. -- The text should not change but the command does.
  4812. -- Also verify that "changed" shows up, which means the mapping triggered.
  4813. command('nnoremap <expr> <F2> ChangeMenu()')
  4814. feed('/X<CR>:popup PopUp<CR><F2>')
  4815. screen:expect([[
  4816. one two three four five |
  4817. and one two {7:^X}three four five |
  4818. one more tw{n: Undo } |
  4819. {1:~ }{n: }{1: }|
  4820. {1:~ }{n: Paste }{1: }|
  4821. {1:~ }{n: }{1: }|
  4822. {1:~ }{n: Select Word }{1: }|
  4823. {1:~ }{n: Select Sentence }{1: }|
  4824. {1:~ }{n: Select Paragraph }{1: }|
  4825. {1:~ }{n: Select Line }{1: }|
  4826. {1:~ }{n: Select Block }{1: }|
  4827. {1:~ }{n: Select All }{1: }|
  4828. {1:~ }|*7
  4829. changed |
  4830. ]])
  4831. -- Select the Paste entry, executes the changed menu item.
  4832. feed('jj<CR>')
  4833. screen:expect([[
  4834. one two three four five |
  4835. and one two {7:^X}three four five |
  4836. one more two three four five |
  4837. {1:~ }|*16
  4838. pasted |
  4839. ]])
  4840. -- Add a window toolbar to the window and check the :popup menu position.
  4841. command('setlocal winbar=TEST')
  4842. feed('/X<CR>:popup PopUp<CR>')
  4843. screen:expect([[
  4844. {2:TEST }|
  4845. one two three four five |
  4846. and one two {7:^X}three four five |
  4847. one more tw{n: Undo } |
  4848. {1:~ }{n: }{1: }|
  4849. {1:~ }{n: Paste }{1: }|
  4850. {1:~ }{n: }{1: }|
  4851. {1:~ }{n: Select Word }{1: }|
  4852. {1:~ }{n: Select Sentence }{1: }|
  4853. {1:~ }{n: Select Paragraph }{1: }|
  4854. {1:~ }{n: Select Line }{1: }|
  4855. {1:~ }{n: Select Block }{1: }|
  4856. {1:~ }{n: Select All }{1: }|
  4857. {1:~ }|*6
  4858. :popup PopUp |
  4859. ]])
  4860. feed('<Esc>')
  4861. end)
  4862. -- oldtest: Test_mouse_popup_position()
  4863. it('position of right-click menu when clicking near edge', function()
  4864. screen:try_resize(50, 20)
  4865. exec([[
  4866. set mousemodel=popup_setpos
  4867. " Delete the default MenuPopup event handler.
  4868. autocmd! nvim.popupmenu
  4869. aunmenu *
  4870. source $VIMRUNTIME/menu.vim
  4871. call setline(1, join(range(20)))
  4872. ]])
  4873. api.nvim_input_mouse('right', 'press', '', 0, 0, 45 - 1)
  4874. screen:expect([[
  4875. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ^18 19 |
  4876. {1:~ }{n: Undo }|
  4877. {1:~ }{n: }|
  4878. {1:~ }{n: Paste }|
  4879. {1:~ }{n: }|
  4880. {1:~ }{n: Select Word }|
  4881. {1:~ }{n: Select Sentence }|
  4882. {1:~ }{n: Select Paragraph}|
  4883. {1:~ }{n: Select Line }|
  4884. {1:~ }{n: Select Block }|
  4885. {1:~ }{n: Select All }|
  4886. {1:~ }|*8
  4887. |
  4888. ]])
  4889. feed('<Esc>')
  4890. command('set rightleft')
  4891. api.nvim_input_mouse('right', 'press', '', 0, 0, 50 - 45)
  4892. screen:expect([[
  4893. 91 8^1 71 61 51 41 31 21 11 01 9 8 7 6 5 4 3 2 1 0|
  4894. {n: odnU }{1: ~}|
  4895. {n: }{1: ~}|
  4896. {n: etsaP }{1: ~}|
  4897. {n: }{1: ~}|
  4898. {n: droW tceleS }{1: ~}|
  4899. {n: ecnetneS tceleS }{1: ~}|
  4900. {n:hpargaraP tceleS }{1: ~}|
  4901. {n: eniL tceleS }{1: ~}|
  4902. {n: kcolB tceleS }{1: ~}|
  4903. {n: llA tceleS }{1: ~}|
  4904. {1: ~}|*8
  4905. |
  4906. ]])
  4907. feed('<Esc>')
  4908. command('set norightleft')
  4909. end)
  4910. describe('"kind" and "menu"', function()
  4911. before_each(function()
  4912. screen:try_resize(30, 8)
  4913. exec([[
  4914. func CompleteFunc( findstart, base )
  4915. if a:findstart
  4916. return 0
  4917. endif
  4918. return {
  4919. \ 'words': [
  4920. \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', },
  4921. \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', },
  4922. \ { 'word': 'aword3', 'menu': 'extra text 3', 'kind': 'W', },
  4923. \]}
  4924. endfunc
  4925. set completeopt=menu
  4926. set completefunc=CompleteFunc
  4927. ]])
  4928. end)
  4929. -- oldtest: Test_pum_highlights_default()
  4930. it('default highlight groups', function()
  4931. feed('iaw<C-X><C-u>')
  4932. screen:expect([[
  4933. aword1^ |
  4934. {s:aword1 W extra text 1 }{1: }|
  4935. {n:aword2 W extra text 2 }{1: }|
  4936. {n:aword3 W extra text 3 }{1: }|
  4937. {1:~ }|*3
  4938. {2:-- }{5:match 1 of 3} |
  4939. ]])
  4940. end)
  4941. -- oldtest: Test_pum_highlights_custom()
  4942. it('custom highlight groups', function()
  4943. exec([[
  4944. hi PmenuKind guifg=Red guibg=Plum1
  4945. hi PmenuKindSel guifg=Red guibg=Grey
  4946. hi PmenuExtra guifg=White guibg=Plum1
  4947. hi PmenuExtraSel guifg=Black guibg=Grey
  4948. ]])
  4949. feed('iaw<C-X><C-u>')
  4950. screen:expect([[
  4951. aword1^ |
  4952. {s:aword1 }{ks:W }{xs:extra text 1 }{1: }|
  4953. {n:aword2 }{kn:W }{xn:extra text 2 }{1: }|
  4954. {n:aword3 }{kn:W }{xn:extra text 3 }{1: }|
  4955. {1:~ }|*3
  4956. {2:-- }{5:match 1 of 3} |
  4957. ]])
  4958. end)
  4959. end)
  4960. -- oldtest: Test_pum_highlights_match()
  4961. it('can highlight matched text', function()
  4962. exec([[
  4963. func Omni_test(findstart, base)
  4964. if a:findstart
  4965. return col(".")
  4966. endif
  4967. return {
  4968. \ 'words': [
  4969. \ { 'word': 'foo', 'kind': 'fookind' },
  4970. \ { 'word': 'foofoo', 'kind': 'fookind' },
  4971. \ { 'word': 'foobar', 'kind': 'fookind' },
  4972. \ { 'word': 'fooBaz', 'kind': 'fookind' },
  4973. \ { 'word': 'foobala', 'kind': 'fookind' },
  4974. \ { 'word': '你好' },
  4975. \ { 'word': '你好吗' },
  4976. \ { 'word': '你不好吗' },
  4977. \ { 'word': '你可好吗' },
  4978. \]}
  4979. endfunc
  4980. func Comp()
  4981. let col = col('.')
  4982. if getline('.') == 'f'
  4983. let col -= 1
  4984. endif
  4985. call complete(col, [
  4986. \ #{word: "foo", icase: 1},
  4987. \ #{word: "Foobar", icase: 1},
  4988. \ #{word: "fooBaz", icase: 1},
  4989. \])
  4990. return ''
  4991. endfunc
  4992. set omnifunc=Omni_test
  4993. set completeopt=menu,noinsert,fuzzy
  4994. hi PmenuMatchSel guifg=Blue guibg=Grey
  4995. hi PmenuMatch guifg=Blue guibg=Plum1
  4996. ]])
  4997. feed('i<C-X><C-O>')
  4998. local pum_start = [[
  4999. ^ |
  5000. {s:foo fookind }{1: }|
  5001. {n:foofoo fookind }{1: }|
  5002. {n:foobar fookind }{1: }|
  5003. {n:fooBaz fookind }{1: }|
  5004. {n:foobala fookind }{1: }|
  5005. {n:你好 }{1: }|
  5006. {n:你好吗 }{1: }|
  5007. {n:你不好吗 }{1: }|
  5008. {n:你可好吗 }{1: }|
  5009. {1:~ }|*9
  5010. {2:-- }{5:match 1 of 9} |
  5011. ]]
  5012. screen:expect(pum_start)
  5013. feed('fo')
  5014. screen:expect([[
  5015. fo^ |
  5016. {ms:fo}{s:o fookind }{1: }|
  5017. {mn:fo}{n:ofoo fookind }{1: }|
  5018. {mn:fo}{n:obar fookind }{1: }|
  5019. {mn:fo}{n:oBaz fookind }{1: }|
  5020. {mn:fo}{n:obala fookind }{1: }|
  5021. {1:~ }|*13
  5022. {2:-- }{5:match 1 of 9} |
  5023. ]])
  5024. feed('<Esc>S<C-X><C-O>')
  5025. screen:expect(pum_start)
  5026. feed('你')
  5027. screen:expect([[
  5028. 你^ |
  5029. {ms:你}{s:好 }{1: }|
  5030. {mn:你}{n:好吗 }{1: }|
  5031. {mn:你}{n:不好吗 }{1: }|
  5032. {mn:你}{n:可好吗 }{1: }|
  5033. {1:~ }|*14
  5034. {2:-- }{5:match 1 of 9} |
  5035. ]])
  5036. feed('吗')
  5037. screen:expect([[
  5038. 你吗^ |
  5039. {ms:你}{s:好}{ms:吗}{s: }{1: }|
  5040. {mn:你}{n:不好}{mn:吗}{n: }{1: }|
  5041. {mn:你}{n:可好}{mn:吗}{n: }{1: }|
  5042. {1:~ }|*15
  5043. {2:-- }{5:match 1 of 9} |
  5044. ]])
  5045. feed('<C-E><Esc>')
  5046. command('set rightleft')
  5047. feed('S<C-X><C-O>')
  5048. local pum_start_rl = [[
  5049. ^ |
  5050. {1: }{s: dnikoof oof}|
  5051. {1: }{n: dnikoof oofoof}|
  5052. {1: }{n: dnikoof raboof}|
  5053. {1: }{n: dnikoof zaBoof}|
  5054. {1: }{n: dnikoof alaboof}|
  5055. {1: }{n: 好你}|
  5056. {1: }{n: 吗好你}|
  5057. {1: }{n: 吗好不你}|
  5058. {1: }{n: 吗好可你}|
  5059. {1: ~}|*9
  5060. {2:-- }{5:match 1 of 9} |
  5061. ]]
  5062. screen:expect(pum_start_rl)
  5063. feed('fo')
  5064. screen:expect([[
  5065. ^ of|
  5066. {1: }{s: dnikoof o}{ms:of}|
  5067. {1: }{n: dnikoof oofo}{mn:of}|
  5068. {1: }{n: dnikoof rabo}{mn:of}|
  5069. {1: }{n: dnikoof zaBo}{mn:of}|
  5070. {1: }{n: dnikoof alabo}{mn:of}|
  5071. {1: ~}|*13
  5072. {2:-- }{5:match 1 of 9} |
  5073. ]])
  5074. feed('<Esc>S<C-X><C-O>')
  5075. screen:expect(pum_start_rl)
  5076. feed('你')
  5077. screen:expect([[
  5078. ^ 你|
  5079. {1: }{s: 好}{ms:你}|
  5080. {1: }{n: 吗好}{mn:你}|
  5081. {1: }{n: 吗好不}{mn:你}|
  5082. {1: }{n: 吗好可}{mn:你}|
  5083. {1: ~}|*14
  5084. {2:-- }{5:match 1 of 9} |
  5085. ]])
  5086. feed('吗')
  5087. screen:expect([[
  5088. ^ 吗你|
  5089. {1: }{s: }{ms:吗}{s:好}{ms:你}|
  5090. {1: }{n: }{mn:吗}{n:好不}{mn:你}|
  5091. {1: }{n: }{mn:吗}{n:好可}{mn:你}|
  5092. {1: ~}|*15
  5093. {2:-- }{5:match 1 of 9} |
  5094. ]])
  5095. feed('<C-E><Esc>')
  5096. command('set norightleft')
  5097. command('set completeopt-=fuzzy')
  5098. feed('S<C-X><C-O>')
  5099. screen:expect(pum_start)
  5100. feed('fo')
  5101. screen:expect([[
  5102. fo^ |
  5103. {ms:fo}{s:o fookind }{1: }|
  5104. {mn:fo}{n:ofoo fookind }{1: }|
  5105. {mn:fo}{n:obar fookind }{1: }|
  5106. {mn:fo}{n:oBaz fookind }{1: }|
  5107. {mn:fo}{n:obala fookind }{1: }|
  5108. {1:~ }|*13
  5109. {2:-- }{5:match 1 of 9} |
  5110. ]])
  5111. feed('<C-E><Esc>')
  5112. command('set rightleft')
  5113. feed('S<C-X><C-O>')
  5114. screen:expect(pum_start_rl)
  5115. feed('fo')
  5116. screen:expect([[
  5117. ^ of|
  5118. {1: }{s: dnikoof o}{ms:of}|
  5119. {1: }{n: dnikoof oofo}{mn:of}|
  5120. {1: }{n: dnikoof rabo}{mn:of}|
  5121. {1: }{n: dnikoof zaBo}{mn:of}|
  5122. {1: }{n: dnikoof alabo}{mn:of}|
  5123. {1: ~}|*13
  5124. {2:-- }{5:match 1 of 9} |
  5125. ]])
  5126. feed('<C-E><Esc>')
  5127. command('set norightleft')
  5128. feed('S<C-R>=Comp()<CR>f')
  5129. screen:expect([[
  5130. f^ |
  5131. {ms:f}{s:oo }{1: }|
  5132. {mn:F}{n:oobar }{1: }|
  5133. {mn:f}{n:ooBaz }{1: }|
  5134. {1:~ }|*15
  5135. {2:-- INSERT --} |
  5136. ]])
  5137. feed('o<BS><C-R>=Comp()<CR>')
  5138. screen:expect_unchanged(true)
  5139. feed('<Esc>')
  5140. command('set completeopt+=fuzzy,menu')
  5141. feed('S hello helio hero h<C-X><C-P>')
  5142. screen:expect([[
  5143. hello helio hero h^ |
  5144. {1:~ }{n: }{mn:h}{n:ello }{1: }|
  5145. {1:~ }{n: }{mn:h}{n:elio }{1: }|
  5146. {1:~ }{s: }{ms:h}{s:ero }{1: }|
  5147. {1:~ }|*15
  5148. {2:-- }{5:match 1 of 3} |
  5149. ]])
  5150. feed('<Esc>S hello helio hero h<C-X><C-P><C-P>')
  5151. screen:expect([[
  5152. hello helio hero h^ |
  5153. {1:~ }{n: }{mn:h}{n:ello }{1: }|
  5154. {1:~ }{s: }{ms:h}{s:elio }{1: }|
  5155. {1:~ }{n: }{mn:h}{n:ero }{1: }|
  5156. {1:~ }|*15
  5157. {2:-- }{5:match 2 of 3} |
  5158. ]])
  5159. feed('<C-E><Esc>')
  5160. end)
  5161. -- oldtest: Test_pum_highlights_match_with_abbr()
  5162. it('can highlight matched text with abbr', function()
  5163. exec([[
  5164. func Omni_test(findstart, base)
  5165. if a:findstart
  5166. return col(".")
  5167. endif
  5168. return {
  5169. \ 'words': [
  5170. \ { 'word': 'foobar', 'abbr': "foobar\t\t!" },
  5171. \ { 'word': 'foobaz', 'abbr': "foobaz\t\t!" },
  5172. \]}
  5173. endfunc
  5174. set omnifunc=Omni_test
  5175. set completeopt=menuone,noinsert
  5176. hi PmenuMatchSel guifg=Blue guibg=Grey
  5177. hi PmenuMatch guifg=Blue guibg=Plum1
  5178. ]])
  5179. feed('i<C-X><C-O>')
  5180. screen:expect([[
  5181. ^ |
  5182. {s:foobar ! }{1: }|
  5183. {n:foobaz ! }{1: }|
  5184. {1:~ }|*16
  5185. {2:-- }{5:match 1 of 2} |
  5186. ]])
  5187. feed('foo')
  5188. screen:expect([[
  5189. foo^ |
  5190. {ms:foo}{s:bar ! }{1: }|
  5191. {mn:foo}{n:baz ! }{1: }|
  5192. {1:~ }|*16
  5193. {2:-- }{5:match 1 of 2} |
  5194. ]])
  5195. feed('<C-E><Esc>')
  5196. end)
  5197. -- oldtest: Test_pum_user_abbr_hlgroup()
  5198. it('custom abbr_hlgroup override', function()
  5199. exec([[
  5200. let s:var = 0
  5201. func CompleteFunc(findstart, base)
  5202. if a:findstart
  5203. return 0
  5204. endif
  5205. if s:var == 1
  5206. return {
  5207. \ 'words': [
  5208. \ { 'word': 'aword1', 'abbr_hlgroup': 'StrikeFake' },
  5209. \ { 'word': '你好', 'abbr_hlgroup': 'StrikeFake' },
  5210. \]}
  5211. endif
  5212. return {
  5213. \ 'words': [
  5214. \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
  5215. \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', },
  5216. \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
  5217. \]}
  5218. endfunc
  5219. func ChangeVar()
  5220. let s:var = 1
  5221. endfunc
  5222. set completeopt=menu
  5223. set completefunc=CompleteFunc
  5224. hi StrikeFake guifg=DarkRed
  5225. func HlMatch()
  5226. hi PmenuMatchSel guifg=Blue guibg=Grey gui=underline
  5227. hi PmenuMatch guifg=Blue guibg=Plum1 gui=underline
  5228. endfunc
  5229. ]])
  5230. feed('Saw<C-X><C-U>')
  5231. screen:expect([[
  5232. aword1^ |
  5233. {ds:aword1}{s: W extra text 1 }{1: }|
  5234. {n:aword2 W extra text 2 }{1: }|
  5235. {dn:你好}{n: W extra text 3 }{1: }|
  5236. {1:~ }|*15
  5237. {2:-- }{5:match 1 of 3} |
  5238. ]])
  5239. feed('<C-E><Esc>')
  5240. command('call HlMatch()')
  5241. feed('Saw<C-X><C-U>')
  5242. screen:expect([[
  5243. aword1^ |
  5244. {uds:aw}{ds:ord1}{s: W extra text 1 }{1: }|
  5245. {umn:aw}{n:ord2 W extra text 2 }{1: }|
  5246. {dn:你好}{n: W extra text 3 }{1: }|
  5247. {1:~ }|*15
  5248. {2:-- }{5:match 1 of 3} |
  5249. ]])
  5250. feed('<C-N>')
  5251. screen:expect([[
  5252. aword2^ |
  5253. {udn:aw}{dn:ord1}{n: W extra text 1 }{1: }|
  5254. {ums:aw}{s:ord2 W extra text 2 }{1: }|
  5255. {dn:你好}{n: W extra text 3 }{1: }|
  5256. {1:~ }|*15
  5257. {2:-- }{5:match 2 of 3} |
  5258. ]])
  5259. feed('<C-E><Esc>')
  5260. command('call ChangeVar()')
  5261. feed('S<C-X><C-U>')
  5262. screen:expect([[
  5263. aword1^ |
  5264. {ds:aword1}{s: }{1: }|
  5265. {dn:你好}{n: }{1: }|
  5266. {1:~ }|*16
  5267. {2:-- }{5:match 1 of 2} |
  5268. ]])
  5269. feed('<C-E><Esc>')
  5270. end)
  5271. -- oldtest: Test_pum_user_kind_hlgroup()
  5272. it('custom kind_hlgroup override', function()
  5273. exec([[
  5274. func CompleteFunc( findstart, base )
  5275. if a:findstart
  5276. return 0
  5277. endif
  5278. return {
  5279. \ 'words': [
  5280. \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'variable', 'kind_hlgroup': 'KindVar', 'abbr_hlgroup': 'StrikeFake' },
  5281. \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'function', 'kind_hlgroup': 'KindFunc' },
  5282. \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'class', 'kind_hlgroup': 'KindClass' },
  5283. \]}
  5284. endfunc
  5285. set completeopt=menu
  5286. set completefunc=CompleteFunc
  5287. hi StrikeFake guifg=DarkRed
  5288. hi KindVar guifg=DarkYellow
  5289. hi KindFunc guifg=DarkBlue
  5290. hi KindClass guifg=DarkGreen
  5291. ]])
  5292. local attr_ids = screen:get_default_attr_ids()
  5293. attr_ids.kvs = { foreground = Screen.colors.DarkYellow, background = Screen.colors.Grey }
  5294. attr_ids.kfn = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Plum1 }
  5295. attr_ids.kcn = { foreground = Screen.colors.DarkGreen, background = Screen.colors.Plum1 }
  5296. screen:set_default_attr_ids(attr_ids)
  5297. feed('S<C-X><C-U>')
  5298. screen:expect([[
  5299. aword1^ |
  5300. {ds:aword1}{s: }{kvs:variable}{s: extra text 1 }{1: }|
  5301. {n:aword2 }{kfn:function}{n: extra text 2 }{1: }|
  5302. {n:你好 }{kcn:class}{n: extra text 3 }{1: }|
  5303. {1:~ }|*15
  5304. {2:-- }{5:match 1 of 3} |
  5305. ]])
  5306. feed('<C-E><Esc>')
  5307. end)
  5308. -- oldtest: Test_pum_completeitemalign()
  5309. it('completeitemalign option', function()
  5310. screen:try_resize(30, 15)
  5311. exec([[
  5312. func Omni_test(findstart, base)
  5313. if a:findstart
  5314. return col(".")
  5315. endif
  5316. return {
  5317. \ 'words': [
  5318. \ { 'word': 'foo', 'kind': 'S', 'menu': 'menu' },
  5319. \ { 'word': 'bar', 'kind': 'T', 'menu': 'menu' },
  5320. \ { 'word': '你好', 'kind': 'C', 'menu': '中文' },
  5321. \]}
  5322. endfunc
  5323. func Omni_long(findstart, base)
  5324. if a:findstart
  5325. return col(".")
  5326. endif
  5327. return {
  5328. \ 'words': [
  5329. \ { 'word': 'loooong_foo', 'kind': 'S', 'menu': 'menu' },
  5330. \ { 'word': 'loooong_bar', 'kind': 'T', 'menu': 'menu' },
  5331. \]}
  5332. endfunc
  5333. set omnifunc=Omni_test
  5334. ]])
  5335. -- T1
  5336. command('set cia=abbr,kind,menu')
  5337. feed('S<C-X><C-O>')
  5338. screen:expect([[
  5339. foo^ |
  5340. {s:foo S menu }{1: }|
  5341. {n:bar T menu }{1: }|
  5342. {n:你好 C 中文 }{1: }|
  5343. {1:~ }|*10
  5344. {2:-- }{5:match 1 of 3} |
  5345. ]])
  5346. feed('<C-E><ESC>')
  5347. -- T2
  5348. command('set cia=abbr,menu,kind')
  5349. feed('S<C-X><C-O>')
  5350. screen:expect([[
  5351. foo^ |
  5352. {s:foo menu S }{1: }|
  5353. {n:bar menu T }{1: }|
  5354. {n:你好 中文 C }{1: }|
  5355. {1:~ }|*10
  5356. {2:-- }{5:match 1 of 3} |
  5357. ]])
  5358. feed('<C-E><ESC>')
  5359. -- T3
  5360. command('set cia=kind,abbr,menu')
  5361. feed('S<C-X><C-O>')
  5362. screen:expect([[
  5363. foo^ |
  5364. {s:S foo menu }{1: }|
  5365. {n:T bar menu }{1: }|
  5366. {n:C 你好 中文 }{1: }|
  5367. {1:~ }|*10
  5368. {2:-- }{5:match 1 of 3} |
  5369. ]])
  5370. feed('<C-E><ESC>')
  5371. -- T4
  5372. command('set cia=kind,menu,abbr')
  5373. feed('S<C-X><C-O>')
  5374. screen:expect([[
  5375. foo^ |
  5376. {s:S menu foo }{1: }|
  5377. {n:T menu bar }{1: }|
  5378. {n:C 中文 你好 }{1: }|
  5379. {1:~ }|*10
  5380. {2:-- }{5:match 1 of 3} |
  5381. ]])
  5382. feed('<C-E><ESC>')
  5383. -- T5
  5384. command('set cia=menu,abbr,kind')
  5385. feed('S<C-X><C-O>')
  5386. screen:expect([[
  5387. foo^ |
  5388. {s:menu foo S }{1: }|
  5389. {n:menu bar T }{1: }|
  5390. {n:中文 你好 C }{1: }|
  5391. {1:~ }|*10
  5392. {2:-- }{5:match 1 of 3} |
  5393. ]])
  5394. feed('<C-E><ESC>')
  5395. -- T6
  5396. command('set cia=menu,kind,abbr')
  5397. feed('S<C-X><C-O>')
  5398. screen:expect([[
  5399. foo^ |
  5400. {s:menu S foo }{1: }|
  5401. {n:menu T bar }{1: }|
  5402. {n:中文 C 你好 }{1: }|
  5403. {1:~ }|*10
  5404. {2:-- }{5:match 1 of 3} |
  5405. ]])
  5406. feed('<C-E><ESC>')
  5407. -- T7
  5408. command('set cia&')
  5409. feed('S<C-X><C-O>')
  5410. screen:expect([[
  5411. foo^ |
  5412. {s:foo S menu }{1: }|
  5413. {n:bar T menu }{1: }|
  5414. {n:你好 C 中文 }{1: }|
  5415. {1:~ }|*10
  5416. {2:-- }{5:match 1 of 3} |
  5417. ]])
  5418. feed('<C-E><ESC>')
  5419. -- Test_pum_completeitemalign_07
  5420. command('set cia=menu,kind,abbr columns=12 cmdheight=2 omnifunc=Omni_long')
  5421. feed('S<C-X><C-O>')
  5422. screen:expect([[
  5423. loooong_foo^ |
  5424. {s:menu S loooo}|
  5425. {n:menu T loooo}|
  5426. {1:~ }|*10
  5427. |
  5428. {2:--} |
  5429. ]])
  5430. feed('<C-E><ESC>')
  5431. end)
  5432. -- oldtest: Test_pum_matchins_highlight()
  5433. it('with ComplMatchIns highlight', function()
  5434. exec([[
  5435. let g:change = 0
  5436. func Omni_test(findstart, base)
  5437. if a:findstart
  5438. return col(".")
  5439. endif
  5440. if g:change == 0
  5441. return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}]
  5442. endif
  5443. return [#{word: "foo", info: "info"}, #{word: "bar"}, #{word: "你好"}]
  5444. endfunc
  5445. set omnifunc=Omni_test
  5446. hi ComplMatchIns guifg=red
  5447. ]])
  5448. feed('Sαβγ <C-X><C-O>')
  5449. screen:expect([[
  5450. αβγ {8:foo}^ |
  5451. {1:~ }{s: foo }{1: }|
  5452. {1:~ }{n: bar }{1: }|
  5453. {1:~ }{n: 你好 }{1: }|
  5454. {1:~ }|*15
  5455. {2:-- }{5:match 1 of 3} |
  5456. ]])
  5457. feed('<C-E><Esc>')
  5458. feed('Sαβγ <C-X><C-O><C-N>')
  5459. screen:expect([[
  5460. αβγ {8:bar}^ |
  5461. {1:~ }{n: foo }{1: }|
  5462. {1:~ }{s: bar }{1: }|
  5463. {1:~ }{n: 你好 }{1: }|
  5464. {1:~ }|*15
  5465. {2:-- }{5:match 2 of 3} |
  5466. ]])
  5467. feed('<C-E><Esc>')
  5468. feed('Sαβγ <C-X><C-O><C-N><C-N>')
  5469. screen:expect([[
  5470. αβγ {8:你好}^ |
  5471. {1:~ }{n: foo }{1: }|
  5472. {1:~ }{n: bar }{1: }|
  5473. {1:~ }{s: 你好 }{1: }|
  5474. {1:~ }|*15
  5475. {2:-- }{5:match 3 of 3} |
  5476. ]])
  5477. feed('<C-E><Esc>')
  5478. -- restore after accept
  5479. feed('Sαβγ <C-X><C-O><C-Y>')
  5480. screen:expect([[
  5481. αβγ foo^ |
  5482. {1:~ }|*18
  5483. {2:-- INSERT --} |
  5484. ]])
  5485. feed('<Esc>')
  5486. -- restore after cancel completion
  5487. feed('Sαβγ <C-X><C-O><Space>')
  5488. screen:expect([[
  5489. αβγ foo ^ |
  5490. {1:~ }|*18
  5491. {2:-- INSERT --} |
  5492. ]])
  5493. feed('<Esc>')
  5494. -- text after the inserted text shouldn't be highlighted
  5495. feed('0ea <C-X><C-O>')
  5496. screen:expect([[
  5497. αβγ {8:foo}^ foo |
  5498. {1:~ }{s: foo }{1: }|
  5499. {1:~ }{n: bar }{1: }|
  5500. {1:~ }{n: 你好 }{1: }|
  5501. {1:~ }|*15
  5502. {2:-- }{5:match 1 of 3} |
  5503. ]])
  5504. feed('<C-P>')
  5505. screen:expect([[
  5506. αβγ ^ foo |
  5507. {1:~ }{n: foo }{1: }|
  5508. {1:~ }{n: bar }{1: }|
  5509. {1:~ }{n: 你好 }{1: }|
  5510. {1:~ }|*15
  5511. {2:-- }{8:Back at original} |
  5512. ]])
  5513. feed('<C-P>')
  5514. screen:expect([[
  5515. αβγ {8:你好}^ foo |
  5516. {1:~ }{n: foo }{1: }|
  5517. {1:~ }{n: bar }{1: }|
  5518. {1:~ }{s: 你好 }{1: }|
  5519. {1:~ }|*15
  5520. {2:-- }{5:match 3 of 3} |
  5521. ]])
  5522. feed('<C-Y>')
  5523. screen:expect([[
  5524. αβγ 你好^ foo |
  5525. {1:~ }|*18
  5526. {2:-- INSERT --} |
  5527. ]])
  5528. feed('<Esc>')
  5529. feed(':let g:change=1<CR>S<C-X><C-O>')
  5530. screen:expect([[
  5531. info |
  5532. {1:~ }|*2
  5533. {3:[Scratch] [Preview] }|
  5534. {8:foo}^ |
  5535. {s:foo }{1: }|
  5536. {n:bar }{1: }|
  5537. {n:你好 }{1: }|
  5538. {1:~ }|*10
  5539. {4:[No Name] [+] }|
  5540. {2:-- }{5:match 1 of 3} |
  5541. ]])
  5542. feed('<Esc>')
  5543. end)
  5544. -- oldtest: Test_pum_matchins_highlight_combine()
  5545. it('with ComplMatchIns, Normal and CursorLine highlights', function()
  5546. exec([[
  5547. func Omni_test(findstart, base)
  5548. if a:findstart
  5549. return col(".")
  5550. endif
  5551. return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}]
  5552. endfunc
  5553. set omnifunc=Omni_test
  5554. hi Normal guibg=blue
  5555. hi CursorLine guibg=green guifg=white
  5556. set cursorline
  5557. call setline(1, 'aaa bbb')
  5558. ]])
  5559. -- when ComplMatchIns is not set, CursorLine applies normally
  5560. feed('0ea <C-X><C-O>')
  5561. screen:expect([[
  5562. {10:aaa foo^ bbb }|
  5563. {1:~ }{s: foo }{1: }|
  5564. {1:~ }{n: bar }{1: }|
  5565. {1:~ }{n: 你好 }{1: }|
  5566. {1:~ }|*15
  5567. {2:-- }{5:match 1 of 3} |
  5568. ]])
  5569. feed('<C-E>')
  5570. screen:expect([[
  5571. {10:aaa ^ bbb }|
  5572. {1:~ }|*18
  5573. {2:-- INSERT --} |
  5574. ]])
  5575. feed('<BS><Esc>')
  5576. -- when ComplMatchIns is set, it is applied over CursorLine
  5577. command('hi ComplMatchIns guifg=Yellow')
  5578. feed('0ea <C-X><C-O>')
  5579. screen:expect([[
  5580. {10:aaa }{9:foo}{10:^ bbb }|
  5581. {1:~ }{s: foo }{1: }|
  5582. {1:~ }{n: bar }{1: }|
  5583. {1:~ }{n: 你好 }{1: }|
  5584. {1:~ }|*15
  5585. {2:-- }{5:match 1 of 3} |
  5586. ]])
  5587. feed('<C-P>')
  5588. screen:expect([[
  5589. {10:aaa ^ bbb }|
  5590. {1:~ }{n: foo }{1: }|
  5591. {1:~ }{n: bar }{1: }|
  5592. {1:~ }{n: 你好 }{1: }|
  5593. {1:~ }|*15
  5594. {2:-- }{8:Back at original} |
  5595. ]])
  5596. feed('<C-P>')
  5597. screen:expect([[
  5598. {10:aaa }{9:你好}{10:^ bbb }|
  5599. {1:~ }{n: foo }{1: }|
  5600. {1:~ }{n: bar }{1: }|
  5601. {1:~ }{s: 你好 }{1: }|
  5602. {1:~ }|*15
  5603. {2:-- }{5:match 3 of 3} |
  5604. ]])
  5605. feed('<C-E>')
  5606. screen:expect([[
  5607. {10:aaa ^ bbb }|
  5608. {1:~ }|*18
  5609. {2:-- INSERT --} |
  5610. ]])
  5611. feed('<Esc>')
  5612. -- Does not highlight the compl leader
  5613. command('set cot+=menuone,noselect')
  5614. feed('S<C-X><C-O>')
  5615. local pum_start = [[
  5616. {10:^ }|
  5617. {n:foo }{1: }|
  5618. {n:bar }{1: }|
  5619. {n:你好 }{1: }|
  5620. {1:~ }|*15
  5621. {2:-- }{8:Back at original} |
  5622. ]]
  5623. screen:expect(pum_start)
  5624. feed('f<C-N>')
  5625. screen:expect([[
  5626. {10:f}{9:oo}{10:^ }|
  5627. {s:foo }{1: }|
  5628. {1:~ }|*17
  5629. {2:-- }{5:match 1 of 3} |
  5630. ]])
  5631. feed('<C-E><ESC>')
  5632. command('set cot+=fuzzy')
  5633. feed('S<C-X><C-O>')
  5634. screen:expect(pum_start)
  5635. feed('f<C-N>')
  5636. screen:expect([[
  5637. {10:foo^ }|
  5638. {s:foo }{1: }|
  5639. {1:~ }|*17
  5640. {2:-- }{5:match 1 of 3} |
  5641. ]])
  5642. feed('<C-E><Esc>')
  5643. command('set cot-=fuzzy')
  5644. feed('Sf<C-N>')
  5645. screen:expect([[
  5646. {10:f^ }|
  5647. {1:~ }|*18
  5648. {2:-- }{6:Pattern not found} |
  5649. ]])
  5650. feed('<C-E><Esc>')
  5651. end)
  5652. end
  5653. end
  5654. describe('with ext_multigrid', function()
  5655. with_ext_multigrid(true)
  5656. end)
  5657. describe('without ext_multigrid', function()
  5658. with_ext_multigrid(false)
  5659. end)
  5660. end)