123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949 |
- local t = require('test.testutil')
- local n = require('test.functional.testnvim')()
- local Screen = require('test.functional.ui.screen')
- local assert_alive = n.assert_alive
- local clear, feed = n.clear, n.feed
- local source = n.source
- local insert = n.insert
- local api = n.api
- local async_meths = n.async_meths
- local command = n.command
- local fn = n.fn
- local eq = t.eq
- local pcall_err = t.pcall_err
- local exec_lua = n.exec_lua
- local exec = n.exec
- describe('ui/ext_popupmenu', function()
- local screen
- before_each(function()
- clear()
- screen = Screen.new(60, 8, { rgb = true, ext_popupmenu = true })
- source([[
- function! TestComplete() abort
- call complete(1, [{'word':'foo', 'abbr':'fo', 'menu':'the foo', 'info':'foo-y', 'kind':'x'}, 'bar', 'spam'])
- return ''
- endfunction
- ]])
- end)
- local expected = {
- { 'fo', 'x', 'the foo', 'foo-y' },
- { 'bar', '', '', '' },
- { 'spam', '', '', '' },
- }
- it('works', function()
- feed('o<C-r>=TestComplete()<CR>')
- screen:expect {
- grid = [[
- |
- foo^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 0,
- anchor = { 1, 1, 0 },
- },
- }
- feed('<c-p>')
- screen:expect {
- grid = [[
- |
- ^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = -1,
- anchor = { 1, 1, 0 },
- },
- }
- -- down moves the selection in the menu, but does not insert anything
- feed('<down><down>')
- screen:expect {
- grid = [[
- |
- ^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 1,
- anchor = { 1, 1, 0 },
- },
- }
- feed('<cr>')
- screen:expect {
- grid = [[
- |
- bar^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- }
- end)
- it('can be controlled by API', function()
- feed('o<C-r>=TestComplete()<CR>')
- screen:expect {
- grid = [[
- |
- foo^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 0,
- anchor = { 1, 1, 0 },
- },
- }
- api.nvim_select_popupmenu_item(1, false, false, {})
- screen:expect {
- grid = [[
- |
- foo^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 1,
- anchor = { 1, 1, 0 },
- },
- }
- api.nvim_select_popupmenu_item(2, true, false, {})
- screen:expect {
- grid = [[
- |
- spam^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 2,
- anchor = { 1, 1, 0 },
- },
- }
- api.nvim_select_popupmenu_item(0, true, true, {})
- screen:expect([[
- |
- foo^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]])
- feed('<c-w><C-r>=TestComplete()<CR>')
- screen:expect {
- grid = [[
- |
- foo^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 0,
- anchor = { 1, 1, 0 },
- },
- }
- api.nvim_select_popupmenu_item(-1, false, false, {})
- screen:expect {
- grid = [[
- |
- foo^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = -1,
- anchor = { 1, 1, 0 },
- },
- }
- api.nvim_select_popupmenu_item(1, true, false, {})
- screen:expect {
- grid = [[
- |
- bar^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 1,
- anchor = { 1, 1, 0 },
- },
- }
- api.nvim_select_popupmenu_item(-1, true, false, {})
- screen:expect {
- grid = [[
- |
- ^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = -1,
- anchor = { 1, 1, 0 },
- },
- }
- api.nvim_select_popupmenu_item(0, true, false, {})
- screen:expect {
- grid = [[
- |
- foo^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 0,
- anchor = { 1, 1, 0 },
- },
- }
- api.nvim_select_popupmenu_item(-1, true, true, {})
- screen:expect([[
- |
- ^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]])
- command('set wildmenu')
- command('set wildoptions=pum')
- local expected_wildpum = {
- { 'define', '', '', '' },
- { 'jump', '', '', '' },
- { 'list', '', '', '' },
- { 'place', '', '', '' },
- { 'undefine', '', '', '' },
- { 'unplace', '', '', '' },
- }
- feed('<Esc>:sign <Tab>')
- screen:expect({
- grid = [[
- |*2
- {1:~ }|*5
- :sign define^ |
- ]],
- popupmenu = {
- items = expected_wildpum,
- pos = 0,
- anchor = { 1, 7, 6 },
- },
- })
- api.nvim_select_popupmenu_item(-1, true, false, {})
- screen:expect({
- grid = [[
- |*2
- {1:~ }|*5
- :sign ^ |
- ]],
- popupmenu = {
- items = expected_wildpum,
- pos = -1,
- anchor = { 1, 7, 6 },
- },
- })
- api.nvim_select_popupmenu_item(5, true, false, {})
- screen:expect({
- grid = [[
- |*2
- {1:~ }|*5
- :sign unplace^ |
- ]],
- popupmenu = {
- items = expected_wildpum,
- pos = 5,
- anchor = { 1, 7, 6 },
- },
- })
- api.nvim_select_popupmenu_item(-1, true, true, {})
- screen:expect({
- grid = [[
- |*2
- {1:~ }|*5
- :sign ^ |
- ]],
- })
- feed('<Tab>')
- screen:expect({
- grid = [[
- |*2
- {1:~ }|*5
- :sign define^ |
- ]],
- popupmenu = {
- items = expected_wildpum,
- pos = 0,
- anchor = { 1, 7, 6 },
- },
- })
- api.nvim_select_popupmenu_item(5, true, true, {})
- screen:expect({
- grid = [[
- |*2
- {1:~ }|*5
- :sign unplace^ |
- ]],
- })
- local function test_pum_select_mappings()
- screen:set_option('ext_popupmenu', true)
- feed('<Esc>A<C-r>=TestComplete()<CR>')
- screen:expect {
- grid = [[
- |
- foo^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 0,
- anchor = { 1, 1, 0 },
- },
- }
- feed('<f1>')
- screen:expect {
- grid = [[
- |
- spam^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 2,
- anchor = { 1, 1, 0 },
- },
- }
- feed('<f2>')
- screen:expect {
- grid = [[
- |
- spam^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = -1,
- anchor = { 1, 1, 0 },
- },
- }
- feed('<f3>')
- screen:expect([[
- |
- bar^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]])
- feed('<Esc>:sign <Tab>')
- screen:expect({
- grid = [[
- |
- bar |
- {1:~ }|*5
- :sign define^ |
- ]],
- popupmenu = {
- items = expected_wildpum,
- pos = 0,
- anchor = { 1, 7, 6 },
- },
- })
- feed('<f1>')
- screen:expect({
- grid = [[
- |
- bar |
- {1:~ }|*5
- :sign list^ |
- ]],
- popupmenu = {
- items = expected_wildpum,
- pos = 2,
- anchor = { 1, 7, 6 },
- },
- })
- feed('<f2>')
- screen:expect({
- grid = [[
- |
- bar |
- {1:~ }|*5
- :sign ^ |
- ]],
- popupmenu = {
- items = expected_wildpum,
- pos = -1,
- anchor = { 1, 7, 6 },
- },
- })
- feed('<f3>')
- screen:expect({
- grid = [[
- |
- bar |
- {1:~ }|*5
- :sign jump^ |
- ]],
- })
- -- also should work for builtin popupmenu
- screen:set_option('ext_popupmenu', false)
- feed('<Esc>A<C-r>=TestComplete()<CR>')
- screen:expect([[
- |
- foo^ |
- {12:fo x the foo }{1: }|
- {4:bar }{1: }|
- {4:spam }{1: }|
- {1:~ }|*2
- {5:-- INSERT --} |
- ]])
- feed('<f1>')
- screen:expect([[
- |
- spam^ |
- {4:fo x the foo }{1: }|
- {4:bar }{1: }|
- {12:spam }{1: }|
- {1:~ }|*2
- {5:-- INSERT --} |
- ]])
- feed('<f2>')
- screen:expect([[
- |
- spam^ |
- {4:fo x the foo }{1: }|
- {4:bar }{1: }|
- {4:spam }{1: }|
- {1:~ }|*2
- {5:-- INSERT --} |
- ]])
- feed('<f3>')
- screen:expect([[
- |
- bar^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]])
- feed('<Esc>:sign <Tab>')
- screen:expect([[
- |
- bar {12: define } |
- {1:~ }{4: jump }{1: }|
- {1:~ }{4: list }{1: }|
- {1:~ }{4: place }{1: }|
- {1:~ }{4: undefine }{1: }|
- {1:~ }{4: unplace }{1: }|
- :sign define^ |
- ]])
- feed('<f1>')
- screen:expect([[
- |
- bar {4: define } |
- {1:~ }{4: jump }{1: }|
- {1:~ }{12: list }{1: }|
- {1:~ }{4: place }{1: }|
- {1:~ }{4: undefine }{1: }|
- {1:~ }{4: unplace }{1: }|
- :sign list^ |
- ]])
- feed('<f2>')
- screen:expect([[
- |
- bar {4: define } |
- {1:~ }{4: jump }{1: }|
- {1:~ }{4: list }{1: }|
- {1:~ }{4: place }{1: }|
- {1:~ }{4: undefine }{1: }|
- {1:~ }{4: unplace }{1: }|
- :sign ^ |
- ]])
- feed('<f3>')
- screen:expect([[
- |
- bar |
- {1:~ }|*5
- :sign jump^ |
- ]])
- end
- command('map! <f1> <cmd>call nvim_select_popupmenu_item(2,v:true,v:false,{})<cr>')
- command('map! <f2> <cmd>call nvim_select_popupmenu_item(-1,v:false,v:false,{})<cr>')
- command('map! <f3> <cmd>call nvim_select_popupmenu_item(1,v:false,v:true,{})<cr>')
- test_pum_select_mappings()
- command('unmap! <f1>')
- command('unmap! <f2>')
- command('unmap! <f3>')
- exec_lua([[
- vim.keymap.set('!', '<f1>', function() vim.api.nvim_select_popupmenu_item(2, true, false, {}) end)
- vim.keymap.set('!', '<f2>', function() vim.api.nvim_select_popupmenu_item(-1, false, false, {}) end)
- vim.keymap.set('!', '<f3>', function() vim.api.nvim_select_popupmenu_item(1, false, true, {}) end)
- ]])
- test_pum_select_mappings()
- feed('<esc>ddiaa bb cc<cr>')
- feed('<c-x><c-n>')
- screen:expect([[
- aa bb cc |
- aa^ |
- {12:aa }{1: }|
- {4:bb }{1: }|
- {4:cc }{1: }|
- {1:~ }|*2
- {5:-- Keyword Local completion (^N^P) }{6:match 1 of 3} |
- ]])
- feed('<f1>')
- screen:expect([[
- aa bb cc |
- cc^ |
- {4:aa }{1: }|
- {4:bb }{1: }|
- {12:cc }{1: }|
- {1:~ }|*2
- {5:-- Keyword Local completion (^N^P) }{6:match 3 of 3} |
- ]])
- feed('<f2>')
- screen:expect([[
- aa bb cc |
- cc^ |
- {4:aa }{1: }|
- {4:bb }{1: }|
- {4:cc }{1: }|
- {1:~ }|*2
- {5:-- Keyword Local completion (^N^P) }{19:Back at original} |
- ]])
- feed('<f3>')
- screen:expect([[
- aa bb cc |
- bb^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]])
- end)
- local function source_complete_month()
- source([[
- function! TestCompleteMonth() abort
- call complete(1, ['January', 'February', 'March', 'April',
- \ 'May', 'June', 'July', 'August',
- \ 'September', 'October', 'November', 'December'])
- return ''
- endfunction
- ]])
- end
- describe('pum_set_height', function()
- it('can set pum height', function()
- source_complete_month()
- local month_expected = {
- { 'January', '', '', '' },
- { 'February', '', '', '' },
- { 'March', '', '', '' },
- { 'April', '', '', '' },
- { 'May', '', '', '' },
- { 'June', '', '', '' },
- { 'July', '', '', '' },
- { 'August', '', '', '' },
- { 'September', '', '', '' },
- { 'October', '', '', '' },
- { 'November', '', '', '' },
- { 'December', '', '', '' },
- }
- local pum_height = 6
- feed('o<C-r>=TestCompleteMonth()<CR>')
- api.nvim_ui_pum_set_height(pum_height)
- feed('<PageDown>')
- -- pos becomes pum_height-2 because it is subtracting 2 to keep some
- -- context in ins_compl_key2count()
- screen:expect {
- grid = [[
- |
- January^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = month_expected,
- pos = pum_height - 2,
- anchor = { 1, 1, 0 },
- },
- }
- end)
- it('an error occurs if set 0 or less', function()
- api.nvim_ui_pum_set_height(1)
- eq('Expected pum height > 0', pcall_err(api.nvim_ui_pum_set_height, 0))
- end)
- it('an error occurs when ext_popupmenu is false', function()
- api.nvim_ui_pum_set_height(1)
- screen:set_option('ext_popupmenu', false)
- eq('It must support the ext_popupmenu option', pcall_err(api.nvim_ui_pum_set_height, 1))
- end)
- end)
- describe('pum_set_bounds', function()
- it('can set pum bounds', function()
- source_complete_month()
- local month_expected = {
- { 'January', '', '', '' },
- { 'February', '', '', '' },
- { 'March', '', '', '' },
- { 'April', '', '', '' },
- { 'May', '', '', '' },
- { 'June', '', '', '' },
- { 'July', '', '', '' },
- { 'August', '', '', '' },
- { 'September', '', '', '' },
- { 'October', '', '', '' },
- { 'November', '', '', '' },
- { 'December', '', '', '' },
- }
- local pum_height = 6
- feed('o<C-r>=TestCompleteMonth()<CR>')
- api.nvim_ui_pum_set_height(pum_height)
- -- set bounds w h r c
- api.nvim_ui_pum_set_bounds(10.5, 5.2, 6.3, 7.4)
- feed('<PageDown>')
- -- pos becomes pum_height-2 because it is subtracting 2 to keep some
- -- context in ins_compl_key2count()
- screen:expect {
- grid = [[
- |
- January^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = month_expected,
- pos = pum_height - 2,
- anchor = { 1, 1, 0 },
- },
- }
- end)
- it('no error occurs if row or col set less than 0', function()
- api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
- api.nvim_ui_pum_set_bounds(1.0, 1.0, -1.0, 0.0)
- api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, -1.0)
- end)
- it('an error occurs if width or height set 0 or less', function()
- api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
- eq('Expected width > 0', pcall_err(api.nvim_ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0))
- eq('Expected height > 0', pcall_err(api.nvim_ui_pum_set_bounds, 1.0, -1.0, 1.0, 0.0))
- end)
- it('an error occurs when ext_popupmenu is false', function()
- api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5)
- screen:set_option('ext_popupmenu', false)
- eq(
- 'UI must support the ext_popupmenu option',
- pcall_err(api.nvim_ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5)
- )
- end)
- end)
- it('<PageUP>, <PageDown> works without ui_pum_set_height', function()
- source_complete_month()
- local month_expected = {
- { 'January', '', '', '' },
- { 'February', '', '', '' },
- { 'March', '', '', '' },
- { 'April', '', '', '' },
- { 'May', '', '', '' },
- { 'June', '', '', '' },
- { 'July', '', '', '' },
- { 'August', '', '', '' },
- { 'September', '', '', '' },
- { 'October', '', '', '' },
- { 'November', '', '', '' },
- { 'December', '', '', '' },
- }
- feed('o<C-r>=TestCompleteMonth()<CR>')
- feed('<PageDown>')
- screen:expect {
- grid = [[
- |
- January^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = month_expected,
- pos = 3,
- anchor = { 1, 1, 0 },
- },
- }
- feed('<PageUp>')
- screen:expect {
- grid = [[
- |
- January^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = month_expected,
- pos = 0,
- anchor = { 1, 1, 0 },
- },
- }
- end)
- it('works with wildoptions=pum', function()
- screen:try_resize(32, 10)
- command('set wildmenu')
- command('set wildoptions=pum')
- local wild_expected = {
- { 'define', '', '', '' },
- { 'jump', '', '', '' },
- { 'list', '', '', '' },
- { 'place', '', '', '' },
- { 'undefine', '', '', '' },
- { 'unplace', '', '', '' },
- }
- feed(':sign ')
- screen:expect([[
- |
- {1:~ }|*8
- :sign ^ |
- ]])
- eq(0, fn.wildmenumode())
- feed('<tab>')
- screen:expect {
- grid = [[
- |
- {1:~ }|*8
- :sign define^ |
- ]],
- popupmenu = { items = wild_expected, pos = 0, anchor = { 1, 9, 6 } },
- }
- eq(1, fn.wildmenumode())
- feed('<left>')
- screen:expect {
- grid = [[
- |
- {1:~ }|*8
- :sign ^ |
- ]],
- popupmenu = { items = wild_expected, pos = -1, anchor = { 1, 9, 6 } },
- }
- feed('<left>')
- screen:expect {
- grid = [[
- |
- {1:~ }|*8
- :sign unplace^ |
- ]],
- popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } },
- }
- feed('x')
- screen:expect([[
- |
- {1:~ }|*8
- :sign unplacex^ |
- ]])
- feed('<esc>')
- -- #10042: make sure shift-tab also triggers the pum
- feed(':sign <S-tab>')
- screen:expect {
- grid = [[
- |
- {1:~ }|*8
- :sign unplace^ |
- ]],
- popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } },
- }
- feed('<esc>')
- eq(0, fn.wildmenumode())
- -- check positioning with multibyte char in pattern
- command('e långfile1')
- command('sp långfile2')
- feed(':b lå<tab>')
- screen:expect {
- grid = [[
- |
- {1:~ }|*3
- {3:långfile2 }|
- |
- {1:~ }|*2
- {2:långfile1 }|
- :b långfile1^ |
- ]],
- popupmenu = {
- anchor = { 1, 9, 3 },
- items = { { 'långfile1', '', '', '' }, { 'långfile2', '', '', '' } },
- pos = 0,
- },
- }
- end)
- it('does not interfere with mousemodel=popup', function()
- exec([[
- set mouse=a mousemodel=popup
- aunmenu PopUp
- " Delete the default MenuPopup event handler.
- autocmd! nvim.popupmenu
- menu PopUp.foo :let g:menustr = 'foo'<CR>
- menu PopUp.bar :let g:menustr = 'bar'<CR>
- menu PopUp.baz :let g:menustr = 'baz'<CR>
- ]])
- feed('o<C-r>=TestComplete()<CR>')
- screen:expect {
- grid = [[
- |
- foo^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = 0,
- anchor = { 1, 1, 0 },
- },
- }
- feed('<c-p>')
- screen:expect {
- grid = [[
- |
- ^ |
- {1:~ }|*5
- {5:-- INSERT --} |
- ]],
- popupmenu = {
- items = expected,
- pos = -1,
- anchor = { 1, 1, 0 },
- },
- }
- feed('<esc>')
- screen:expect {
- grid = [[
- |
- ^ |
- {1:~ }|*5
- |
- ]],
- }
- feed('<RightMouse><0,0>')
- screen:expect([[
- |
- {4:^foo } |
- {4:bar }{1: }|
- {4:baz }{1: }|
- {1:~ }|*3
- |
- ]])
- feed('<esc>')
- screen:expect([[
- |
- ^ |
- {1:~ }|*5
- |
- ]])
- end)
- end)
- describe("builtin popupmenu 'pumblend'", function()
- before_each(clear)
- it('RGB-color', function()
- local screen = Screen.new(60, 14)
- screen:set_default_attr_ids({
- [1] = { background = Screen.colors.Yellow },
- [2] = { bold = true, reverse = true },
- [3] = { bold = true, foreground = Screen.colors.Brown },
- [4] = { foreground = Screen.colors.Blue1 },
- [5] = { reverse = true },
- [6] = { background = Screen.colors.Gray55, foreground = Screen.colors.Grey45 },
- [7] = { background = Screen.colors.Gray55, foreground = Screen.colors.Grey0 },
- [8] = { background = tonumber('0x191919'), foreground = Screen.colors.Grey0 },
- [9] = { background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8e5') },
- [10] = { background = tonumber('0xffc1ff'), foreground = Screen.colors.Grey0 },
- [11] = { foreground = tonumber('0xffc1ff'), background = tonumber('0xe5a8e5'), bold = true },
- [12] = { foreground = Screen.colors.Grey55, background = Screen.colors.Gray45, bold = true },
- [13] = { background = tonumber('0xffc1e5'), foreground = Screen.colors.Grey0 },
- [14] = { background = tonumber('0xffc1e5'), foreground = tonumber('0xe5a8e5') },
- [15] = { background = tonumber('0xffc1ff'), foreground = tonumber('0x080202') },
- [16] = { background = tonumber('0xffc1ff'), bold = true, foreground = tonumber('0xf6ace9') },
- [17] = { background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8ff') },
- [18] = { background = tonumber('0xe5a8e5'), foreground = tonumber('0xffc1ff') },
- [19] = { background = Screen.colors.Gray45, foreground = Screen.colors.Grey55 },
- [20] = { bold = true },
- [21] = { bold = true, foreground = Screen.colors.SeaGreen4 },
- [22] = { background = Screen.colors.WebGray },
- [23] = { background = Screen.colors.Grey0 },
- [24] = { background = Screen.colors.LightMagenta },
- [25] = { background = Screen.colors.Gray75, foreground = Screen.colors.Grey25 },
- [26] = { background = Screen.colors.Gray75, foreground = Screen.colors.Grey0 },
- [27] = { background = Screen.colors.Gray50, foreground = Screen.colors.Grey0 },
- [28] = { background = tonumber('0xffddff'), foreground = tonumber('0x7f5d7f') },
- [29] = { background = tonumber('0xffddff'), foreground = Screen.colors.Grey0 },
- [30] = { foreground = tonumber('0xffddff'), background = tonumber('0x7f5d7f'), bold = true },
- [31] = { foreground = tonumber('0xffddff'), background = Screen.colors.Grey0, bold = true },
- [32] = { foreground = Screen.colors.Gray75, background = Screen.colors.Grey25, bold = true },
- [33] = { background = tonumber('0xffdd7f'), foreground = Screen.colors.Grey0 },
- [34] = { background = tonumber('0xffdd7f'), foreground = tonumber('0x7f5d7f') },
- [35] = { background = tonumber('0xffddff'), bold = true, foreground = tonumber('0x290a0a') },
- [36] = { background = tonumber('0xffddff'), bold = true, foreground = tonumber('0xd27294') },
- [37] = { background = tonumber('0xffddff'), foreground = tonumber('0x7f5dff') },
- [38] = { background = tonumber('0x7f5d7f'), foreground = tonumber('0xffddff') },
- [39] = { background = Screen.colors.Grey0, foreground = tonumber('0xffddff') },
- [40] = { background = Screen.colors.Gray25, foreground = Screen.colors.Grey75 },
- [41] = { background = tonumber('0xffddff'), foreground = tonumber('0x00003f') },
- [42] = { foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5') },
- [43] = { background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f') },
- [44] = { foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f') },
- [45] = { background = Screen.colors.WebGray, blend = 0 },
- })
- command('syntax on')
- command('set mouse=a')
- command('set pumblend=10')
- insert([[
- Lorem ipsum dolor sit amet, consectetur
- adipisicing elit, sed do eiusmod tempor
- incididunt ut labore et dolore magna aliqua.
- Ut enim ad minim veniam, quis nostrud
- exercitation ullamco laboris nisi ut aliquip ex
- ea commodo consequat. Duis aute irure dolor in
- reprehenderit in voluptate velit esse cillum
- dolore eu fugiat nulla pariatur. Excepteur sint
- occaecat cupidatat non proident, sunt in culpa
- qui officia deserunt mollit anim id est
- laborum.]])
- command('match Statement /el/')
- command('2match Comment /ut/')
- command('1')
- command('split')
- command('/ol')
- screen:expect([[
- Lorem ipsum d{1:ol}or sit amet, consectetur |
- adipisicing elit, sed do eiusmod tempor |
- ^incididunt ut labore et d{1:ol}ore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- exercitation ullamco laboris nisi ut aliquip ex |
- ea commodo consequat. Duis aute irure d{1:ol}or in |
- {2:[No Name] [+] }|
- Lorem ipsum d{1:ol}or sit amet, consectetur |
- adipisicing {3:el}it, sed do eiusmod tempor |
- incididunt {4:ut} labore et d{1:ol}ore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- exercitation ullamco laboris nisi {4:ut} aliquip ex |
- {5:[No Name] [+] }|
- |
- ]])
- feed('Obla bla <c-x><c-n>')
- screen:expect([[
- Lorem ipsum d{1:ol}or sit amet, consectetur |
- adipisicing elit, sed do eiusmod tempor |
- bla bla incididunt^ |
- incidid{6:u}{7:incididunt}{6:re et}{8: }d{1:ol}ore magna aliqua. |
- Ut enim{9: }{10:ut}{9: minim veniam}{6:,} quis nostrud |
- exercit{9:a}{10:labore}{9:llamco la}{6:b}oris nisi ut aliquip ex |
- {2:[No Nam}{11:e}{42:et}{11:[+] }{12: }{2: }|
- Lorem i{9:p}{10:dolor}{13:e}{14:l}{9:or sit a}{6:m}et, consectetur |
- adipisi{9:c}{10:magn}{15:a}{16:l}{9:it, sed d}{6:o} eiusmod tempor |
- bla bla{9: }{10:aliqua}{9:dunt }{6: } |
- incidid{9:u}{10:Ut}{9: }{17:ut}{9: labore et}{6: }d{1:ol}ore magna aliqua. |
- Ut enim{9: }{10:enim}{9:inim veniam}{6:,} quis nostrud |
- {5:[No Nam}{18:e}{42:ad}{18:[+] }{19: }{5: }|
- {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
- ]])
- command('set pumblend=0')
- screen:expect([[
- Lorem ipsum d{1:ol}or sit amet, consectetur |
- adipisicing elit, sed do eiusmod tempor |
- bla bla incididunt^ |
- incidid{22: incididunt }{23: }d{1:ol}ore magna aliqua. |
- Ut enim{24: ut }{22: } quis nostrud |
- exercit{24: labore }{22: }oris nisi ut aliquip ex |
- {2:[No Nam}{24: et }{22: }{2: }|
- Lorem i{24: dolore }{22: }et, consectetur |
- adipisi{24: magna }{22: } eiusmod tempor |
- bla bla{24: aliqua }{22: } |
- incidid{24: Ut }{22: }d{1:ol}ore magna aliqua. |
- Ut enim{24: enim }{22: } quis nostrud |
- {5:[No Nam}{24: ad }{22: }{5: }|
- {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
- ]])
- command('set pumblend=50')
- screen:expect([[
- Lorem ipsum d{1:ol}or sit amet, consectetur |
- adipisicing elit, sed do eiusmod tempor |
- bla bla incididunt^ |
- incidid{25:u}{26:incididunt}{25:re et}{27: }d{1:ol}ore magna aliqua. |
- Ut enim{28: }{29:ut}{28: minim veniam}{25:,} quis nostrud |
- exercit{28:a}{29:labore}{28:llamco la}{25:b}oris nisi ut aliquip ex |
- {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }|
- Lorem i{28:p}{29:dolor}{33:e}{34:l}{28:or sit a}{25:m}et, consectetur |
- adipisi{28:c}{29:magn}{35:a}{36:l}{28:it, sed d}{25:o} eiusmod tempor |
- bla bla{28: }{29:aliqua}{28:dunt }{25: } |
- incidid{28:u}{29:Ut}{28: }{37:ut}{28: labore et}{25: }d{1:ol}ore magna aliqua. |
- Ut enim{28: }{29:enim}{28:inim veniam}{25:,} quis nostrud |
- {5:[No Nam}{38:e}{44:ad}{38:[+] }{40: }{5: }|
- {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
- ]])
- api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
- screen:expect([[
- Lorem ipsum d{1:ol}or sit amet, consectetur |
- adipisicing elit, sed do eiusmod tempor |
- bla bla incididunt^ |
- incidid{25:u}{26:incididunt}{25:re et}{27: }d{1:ol}ore magna aliqua. |
- Ut enim{28: }{29:ut}{28: minim veniam}{25:,} quis nostrud |
- exercit{28:a}{29:labore}{28:llamco la}{25:b}oris nisi ut aliquip ex |
- {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }|
- incidid{28:u}{29:dol}{41:or}{29:e}{28:labore et}{25: }d{1:ol}ore magna aliqua. |
- Ut enim{28: }{29:magna}{28:nim veniam}{25:,} quis nostrud |
- exercit{28:a}{29:aliqua}{28:llamco la}{25:b}oris nisi {4:ut} aliquip ex |
- ea comm{28:o}{29:Ut}{28: consequat. D}{25:u}is a{4:ut}e irure d{1:ol}or in |
- reprehe{28:n}{29:enim}{28:t in v}{34:ol}{28:upt}{25:a}te v{3:el}it esse cillum |
- {5:[No Nam}{38:e}{44:ad}{38:[+] }{40: }{5: }|
- {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
- ]])
- -- can disable blending for individual attribute. For instance current
- -- selected item. (also tests that `hi Pmenu*` take immediate effect)
- command('hi PMenuSel blend=0')
- screen:expect([[
- Lorem ipsum d{1:ol}or sit amet, consectetur |
- adipisicing elit, sed do eiusmod tempor |
- bla bla incididunt^ |
- incidid{45: incididunt }{27: }d{1:ol}ore magna aliqua. |
- Ut enim{28: }{29:ut}{28: minim veniam}{25:,} quis nostrud |
- exercit{28:a}{29:labore}{28:llamco la}{25:b}oris nisi ut aliquip ex |
- {2:[No Nam}{30:e}{43:et}{30:[+] }{32: }{2: }|
- incidid{28:u}{29:dol}{41:or}{29:e}{28:labore et}{25: }d{1:ol}ore magna aliqua. |
- Ut enim{28: }{29:magna}{28:nim veniam}{25:,} quis nostrud |
- exercit{28:a}{29:aliqua}{28:llamco la}{25:b}oris nisi {4:ut} aliquip ex |
- ea comm{28:o}{29:Ut}{28: consequat. D}{25:u}is a{4:ut}e irure d{1:ol}or in |
- reprehe{28:n}{29:enim}{28:t in v}{34:ol}{28:upt}{25:a}te v{3:el}it esse cillum |
- {5:[No Nam}{38:e}{44:ad}{38:[+] }{40: }{5: }|
- {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} |
- ]])
- feed('<c-e>')
- screen:expect([[
- Lorem ipsum d{1:ol}or sit amet, consectetur |
- adipisicing elit, sed do eiusmod tempor |
- bla bla ^ |
- incididunt ut labore et d{1:ol}ore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- exercitation ullamco laboris nisi ut aliquip ex |
- {2:[No Name] [+] }|
- incididunt {4:ut} labore et d{1:ol}ore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- exercitation ullamco laboris nisi {4:ut} aliquip ex |
- ea commodo consequat. Duis a{4:ut}e irure d{1:ol}or in |
- reprehenderit in v{1:ol}uptate v{3:el}it esse cillum |
- {5:[No Name] [+] }|
- {20:-- INSERT --} |
- ]])
- end)
- it('256-color (non-RGB)', function()
- local screen = Screen.new(60, 8, { rgb = false })
- screen:set_default_attr_ids({
- [1] = { foreground = Screen.colors.Grey0, background = tonumber('0x000007') },
- [2] = { foreground = tonumber('0x000055'), background = tonumber('0x000007') },
- [3] = { foreground = tonumber('0x00008f'), background = Screen.colors.Grey0 },
- [4] = { foreground = Screen.colors.Grey0, background = tonumber('0x0000e1') },
- [5] = { foreground = tonumber('0x0000d1'), background = tonumber('0x0000e1') },
- [6] = { foreground = Screen.colors.NavyBlue, background = tonumber('0x0000f8') },
- [7] = { foreground = tonumber('0x0000a5'), background = tonumber('0x0000f8') },
- [8] = { foreground = tonumber('0x00000c') },
- [9] = { bold = true },
- [10] = { foreground = tonumber('0x000002') },
- })
- command('set pumblend=10')
- insert([[
- Lorem ipsum dolor sit amet, consectetur
- adipisicing elit, sed do eiusmod tempor
- incididunt ut labore et dolore magna aliqua.
- Ut enim ad minim veniam, quis nostrud
- laborum.]])
- feed('ggOdo<c-x><c-n>')
- screen:expect([[
- dolor^ |
- {1:dolor}{2: ipsum dol}or sit amet, consectetur |
- {4:do}{5:ipisicing eli}t, sed do eiusmod tempor |
- {4:dolore}{5:dunt ut l}abore et dolore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- laborum. |
- {8:~ }|
- {9:-- Keyword Local completion (^N^P) }{10:match 1 of 3} |
- ]])
- end)
- end)
- describe('builtin popupmenu', function()
- before_each(clear)
- local function with_ext_multigrid(multigrid)
- local screen
- before_each(function()
- screen = Screen.new(32, 20, { ext_multigrid = multigrid })
- screen:set_default_attr_ids({
- -- popup selected item / scrollbar track
- s = { background = Screen.colors.Grey },
- -- popup non-selected item
- n = { background = Screen.colors.Plum1 },
- -- popup scrollbar knob
- c = { background = Screen.colors.Black },
- [1] = { bold = true, foreground = Screen.colors.Blue },
- [2] = { bold = true },
- [3] = { reverse = true },
- [4] = { bold = true, reverse = true },
- [5] = { bold = true, foreground = Screen.colors.SeaGreen },
- [6] = { foreground = Screen.colors.White, background = Screen.colors.Red },
- [7] = { background = Screen.colors.Yellow }, -- Search
- [8] = { foreground = Screen.colors.Red },
- [9] = { foreground = Screen.colors.Yellow, background = Screen.colors.Green },
- [10] = { foreground = Screen.colors.White, background = Screen.colors.Green },
- ks = { foreground = Screen.colors.Red, background = Screen.colors.Grey },
- kn = { foreground = Screen.colors.Red, background = Screen.colors.Plum1 },
- xs = { foreground = Screen.colors.Black, background = Screen.colors.Grey },
- xn = { foreground = Screen.colors.White, background = Screen.colors.Plum1 },
- ms = { foreground = Screen.colors.Blue, background = Screen.colors.Grey },
- mn = { foreground = Screen.colors.Blue, background = Screen.colors.Plum1 },
- ds = { foreground = Screen.colors.DarkRed, background = Screen.colors.Grey },
- dn = { foreground = Screen.colors.DarkRed, background = Screen.colors.Plum1 },
- ums = {
- foreground = Screen.colors.Blue,
- background = Screen.colors.Grey,
- underline = true,
- },
- umn = {
- foreground = Screen.colors.Blue,
- background = Screen.colors.Plum1,
- underline = true,
- },
- uds = {
- foreground = Screen.colors.DarkRed,
- background = Screen.colors.Grey,
- underline = true,
- },
- udn = {
- foreground = Screen.colors.DarkRed,
- background = Screen.colors.Plum1,
- underline = true,
- },
- })
- end)
- it('with preview-window above', function()
- feed(':ped<CR><c-w>4+')
- feed('iaa bb cc dd ee ff gg hh ii jj<cr>')
- feed('<c-x><c-n>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [4:--------------------------------]|*8
- {3:[No Name] [Preview][+] }|
- [2:--------------------------------]|*9
- {4:[No Name] [+] }|
- [3:--------------------------------]|
- ## grid 2
- aa bb cc dd ee ff gg hh ii jj |
- aa^ |
- {1:~ }|*7
- ## grid 3
- {2:-- }{5:match 1 of 10} |
- ## grid 4
- aa bb cc dd ee ff gg hh ii jj |
- aa |
- {1:~ }|*6
- ## grid 5
- {s:aa }{c: }|
- {n:bb }{c: }|
- {n:cc }{c: }|
- {n:dd }{c: }|
- {n:ee }{c: }|
- {n:ff }{c: }|
- {n:gg }{s: }|
- {n:hh }{s: }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 2, 2, 0, false, 100 },
- },
- }
- else
- screen:expect([[
- aa bb cc dd ee ff gg hh ii jj |
- aa |
- {1:~ }|*6
- {3:[No Name] [Preview][+] }|
- aa bb cc dd ee ff gg hh ii jj |
- aa^ |
- {s:aa }{c: }{1: }|
- {n:bb }{c: }{1: }|
- {n:cc }{c: }{1: }|
- {n:dd }{c: }{1: }|
- {n:ee }{c: }{1: }|
- {n:ff }{c: }{1: }|
- {n:gg }{s: }{1: }|
- {n:hh }{s: }{4: }|
- {2:-- }{5:match 1 of 10} |
- ]])
- end
- end)
- it('with preview-window below', function()
- feed(':ped<CR><c-w>4+<c-w>r')
- feed('iaa bb cc dd ee ff gg hh ii jj<cr>')
- feed('<c-x><c-n>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:--------------------------------]|*9
- {4:[No Name] [+] }|
- [4:--------------------------------]|*8
- {3:[No Name] [Preview][+] }|
- [3:--------------------------------]|
- ## grid 2
- aa bb cc dd ee ff gg hh ii jj |
- aa^ |
- {1:~ }|*7
- ## grid 3
- {2:-- }{5:match 1 of 10} |
- ## grid 4
- aa bb cc dd ee ff gg hh ii jj |
- aa |
- {1:~ }|*6
- ## grid 5
- {s:aa }{c: }|
- {n:bb }{c: }|
- {n:cc }{c: }|
- {n:dd }{c: }|
- {n:ee }{c: }|
- {n:ff }{c: }|
- {n:gg }{s: }|
- {n:hh }{s: }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 2, 2, 0, false, 100 },
- },
- }
- else
- screen:expect([[
- aa bb cc dd ee ff gg hh ii jj |
- aa^ |
- {s:aa }{c: }{1: }|
- {n:bb }{c: }{1: }|
- {n:cc }{c: }{1: }|
- {n:dd }{c: }{1: }|
- {n:ee }{c: }{1: }|
- {n:ff }{c: }{1: }|
- {n:gg }{s: }{1: }|
- {n:hh }{s: }{4: }|
- aa bb cc dd ee ff gg hh ii jj |
- aa |
- {1:~ }|*6
- {3:[No Name] [Preview][+] }|
- {2:-- }{5:match 1 of 10} |
- ]])
- end
- end)
- it('with preview-window above and tall and inverted', function()
- feed(':ped<CR><c-w>8+')
- feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
- feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
- feed('kk<cr>ll<cr>mm<cr>nn<cr>oo<cr>')
- feed('<c-x><c-n>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [4:--------------------------------]|*4
- {3:[No Name] [Preview][+] }|
- [2:--------------------------------]|*13
- {4:[No Name] [+] }|
- [3:--------------------------------]|
- ## grid 2
- dd |
- ee |
- ff |
- gg |
- hh |
- ii |
- jj |
- kk |
- ll |
- mm |
- nn |
- oo |
- aa^ |
- ## grid 3
- {2:-- }{5:match 1 of 15} |
- ## grid 4
- aa |
- bb |
- cc |
- dd |
- ## grid 5
- {s:aa }{c: }|
- {n:bb }{c: }|
- {n:cc }{c: }|
- {n:dd }{c: }|
- {n:ee }{c: }|
- {n:ff }{c: }|
- {n:gg }{c: }|
- {n:hh }{c: }|
- {n:ii }{c: }|
- {n:jj }{c: }|
- {n:kk }{c: }|
- {n:ll }{s: }|
- {n:mm }{s: }|
- ]],
- float_pos = {
- [5] = { -1, 'SW', 2, 12, 0, false, 100 },
- },
- }
- else
- screen:expect([[
- aa |
- bb |
- cc |
- dd |
- {s:aa }{c: }{3:ew][+] }|
- {n:bb }{c: } |
- {n:cc }{c: } |
- {n:dd }{c: } |
- {n:ee }{c: } |
- {n:ff }{c: } |
- {n:gg }{c: } |
- {n:hh }{c: } |
- {n:ii }{c: } |
- {n:jj }{c: } |
- {n:kk }{c: } |
- {n:ll }{s: } |
- {n:mm }{s: } |
- aa^ |
- {4:[No Name] [+] }|
- {2:-- }{5:match 1 of 15} |
- ]])
- end
- end)
- it('with preview-window above and short and inverted', function()
- feed(':ped<CR><c-w>4+')
- feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
- feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
- feed('<c-x><c-n>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [4:--------------------------------]|*8
- {3:[No Name] [Preview][+] }|
- [2:--------------------------------]|*9
- {4:[No Name] [+] }|
- [3:--------------------------------]|
- ## grid 2
- cc |
- dd |
- ee |
- ff |
- gg |
- hh |
- ii |
- jj |
- aa^ |
- ## grid 3
- {2:-- }{5:match 1 of 10} |
- ## grid 4
- aa |
- bb |
- cc |
- dd |
- ee |
- ff |
- gg |
- hh |
- ## grid 5
- {s:aa }{c: }|
- {n:bb }{c: }|
- {n:cc }{c: }|
- {n:dd }{c: }|
- {n:ee }{c: }|
- {n:ff }{c: }|
- {n:gg }{c: }|
- {n:hh }{c: }|
- {n:ii }{s: }|
- ]],
- float_pos = {
- [5] = { -1, 'SW', 2, 8, 0, false, 100 },
- },
- }
- else
- screen:expect([[
- aa |
- bb |
- cc |
- dd |
- ee |
- ff |
- gg |
- hh |
- {s:aa }{c: }{3:ew][+] }|
- {n:bb }{c: } |
- {n:cc }{c: } |
- {n:dd }{c: } |
- {n:ee }{c: } |
- {n:ff }{c: } |
- {n:gg }{c: } |
- {n:hh }{c: } |
- {n:ii }{s: } |
- aa^ |
- {4:[No Name] [+] }|
- {2:-- }{5:match 1 of 10} |
- ]])
- end
- end)
- it('with preview-window below and inverted', function()
- feed(':ped<CR><c-w>4+<c-w>r')
- feed('iaa<cr>bb<cr>cc<cr>dd<cr>ee<cr>')
- feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>')
- feed('<c-x><c-n>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:--------------------------------]|*9
- {4:[No Name] [+] }|
- [4:--------------------------------]|*8
- {3:[No Name] [Preview][+] }|
- [3:--------------------------------]|
- ## grid 2
- cc |
- dd |
- ee |
- ff |
- gg |
- hh |
- ii |
- jj |
- aa^ |
- ## grid 3
- {2:-- }{5:match 1 of 10} |
- ## grid 4
- aa |
- bb |
- cc |
- dd |
- ee |
- ff |
- gg |
- hh |
- ## grid 5
- {s:aa }{c: }|
- {n:bb }{c: }|
- {n:cc }{c: }|
- {n:dd }{c: }|
- {n:ee }{c: }|
- {n:ff }{c: }|
- {n:gg }{s: }|
- {n:hh }{s: }|
- ]],
- float_pos = {
- [5] = { -1, 'SW', 2, 8, 0, false, 100 },
- },
- }
- else
- screen:expect([[
- {s:aa }{c: } |
- {n:bb }{c: } |
- {n:cc }{c: } |
- {n:dd }{c: } |
- {n:ee }{c: } |
- {n:ff }{c: } |
- {n:gg }{s: } |
- {n:hh }{s: } |
- aa^ |
- {4:[No Name] [+] }|
- aa |
- bb |
- cc |
- dd |
- ee |
- ff |
- gg |
- hh |
- {3:[No Name] [Preview][+] }|
- {2:-- }{5:match 1 of 10} |
- ]])
- end
- end)
- if not multigrid then
- describe('popup and preview window do not overlap', function()
- before_each(function()
- screen:try_resize(53, 20)
- end)
- -- oldtest: Test_popup_and_previewwindow_dump_pedit()
- it('with :pedit', function()
- exec([[
- set previewheight=9
- silent! pedit
- call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
- exec "norm! G\<C-E>\<C-E>"
- ]])
- feed('o')
- n.poke_eventloop()
- feed('<C-X><C-N>')
- screen:expect([[
- ab0 |
- ab1 |
- ab2 |
- ab3 |
- ab4 |
- ab5 |
- ab6 |
- ab7 |
- ab8 |
- {s:ab0 }{c: }{3:ew][+] }|
- {n:ab1 }{c: } |
- {n:ab2 }{c: } |
- {n:ab3 }{c: } |
- {n:ab4 }{s: } |
- {n:ab5 }{s: } |
- {n:ab6 }{s: } |
- ab0^ |
- {1:~ }|
- {4:[No Name] [+] }|
- {2:-- Keyword Local completion (^N^P) }{5:match 1 of 10} |
- ]])
- end)
- -- oldtest: Test_popup_and_previewwindow_dump_pbuffer()
- it('with :pbuffer', function()
- exec([[
- set previewheight=9
- silent! pbuffer
- call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
- exec "norm! G\<C-E>\<C-E>\<C-E>"
- ]])
- feed('o')
- n.poke_eventloop()
- feed('<C-X><C-N>')
- screen:expect([[
- ab0 |
- ab1 |
- ab2 |
- ab3 |
- ab4 |
- ab5 |
- ab6 |
- ab7 |
- ab8 |
- {s:ab0 }{c: }{3:ew][+] }|
- {n:ab1 }{c: } |
- {n:ab2 }{c: } |
- {n:ab3 }{s: } |
- {n:ab4 }{s: } |
- {n:ab5 }{s: } |
- ab0^ |
- {1:~ }|*2
- {4:[No Name] [+] }|
- {2:-- Keyword Local completion (^N^P) }{5:match 1 of 10} |
- ]])
- end)
- end)
- -- oldtest: Test_pum_with_preview_win()
- it('preview window opened during completion', function()
- exec([[
- funct Omni_test(findstart, base)
- if a:findstart
- return col(".") - 1
- endif
- return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}]
- endfunc
- set omnifunc=Omni_test
- set completeopt+=longest
- ]])
- feed('Gi<C-X><C-O>')
- screen:expect([[
- ^ |
- {n:one }{1: }|
- {n:two }{1: }|
- {n:three }{1: }|
- {1:~ }|*15
- {2:-- }{8:Back at original} |
- ]])
- feed('<C-N>')
- screen:expect([[
- 1info |
- {1:~ }|*2
- {3:[Scratch] [Preview] }|
- one^ |
- {s:one }{1: }|
- {n:two }{1: }|
- {n:three }{1: }|
- {1:~ }|*10
- {4:[No Name] [+] }|
- {2:-- }{5:match 1 of 3} |
- ]])
- end)
- -- oldtest: Test_scrollbar_on_wide_char()
- it('scrollbar overwrites half of double-width char below properly', function()
- screen:try_resize(32, 10)
- exec([[
- call setline(1, ['a', ' 啊啊啊',
- \ ' 哦哦哦',
- \ ' 呃呃呃'])
- call setline(5, range(10)->map({i, v -> 'aa' .. v .. 'bb'}))
- ]])
- feed('A<C-X><C-N>')
- screen:expect([[
- aa0bb^ |
- {s:aa0bb }{c: }啊 |
- {n:aa1bb }{c: } 哦 |
- {n:aa2bb }{c: }呃呃 |
- {n:aa3bb }{c: } |
- {n:aa4bb }{c: } |
- {n:aa5bb }{c: } |
- {n:aa6bb }{s: } |
- {n:aa7bb }{s: } |
- {2:-- }{5:match 1 of 10} |
- ]])
- end)
- end
- describe('floating window preview popup', function()
- it('pum popup preview', function()
- --row must > 10
- screen:try_resize(40, 11)
- exec([[
- funct Omni_test(findstart, base)
- if a:findstart
- return col(".") - 1
- endif
- return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "looooooooooooooong"}]
- endfunc
- set omnifunc=Omni_test
- set completeopt=menu,popup
- funct Set_info()
- let comp_info = complete_info()
- if comp_info['selected'] == 2
- call nvim__complete_set(comp_info['selected'], {"info": "3info"})
- endif
- endfunc
- funct TsHl()
- let comp_info = complete_info()
- if get(comp_info, 'previewbufnr', 0) > 0
- call v:lua.vim.treesitter.start(comp_info['preview_bufnr'], 'markdown')
- endif
- if comp_info['selected'] == 0
- call nvim__complete_set(comp_info['selected'], {"info": "```lua\nfunction test()\n print('foo')\nend\n```"})
- endif
- endfunc
- augroup Group
- au!
- autocmd CompleteChanged * :call Set_info()
- augroup END
- funct TestTs()
- autocmd! Group
- autocmd CompleteChanged * call TsHl()
- endfunc
- ]])
- feed('Gi<C-x><C-o>')
- --floating preview in right
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:----------------------------------------]|*10
- [3:----------------------------------------]|
- ## grid 2
- one^ |
- {1:~ }|*9
- ## grid 3
- {2:-- }{5:match 1 of 3} |
- ## grid 4
- {n:1info}|
- {n: }|
- ## grid 5
- {s:one }|
- {n:two }|
- {n:looooooooooooooong }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 2, 1, 0, false, 100 },
- [4] = { 1001, 'NW', 1, 1, 19, false, 50 },
- },
- win_viewport = {
- [2] = {
- win = 1000,
- topline = 0,
- botline = 2,
- curline = 0,
- curcol = 3,
- linecount = 1,
- sum_scroll_delta = 0,
- },
- [4] = {
- win = 1001,
- topline = 0,
- botline = 2,
- curline = 0,
- curcol = 0,
- linecount = 1,
- sum_scroll_delta = 0,
- },
- },
- }
- else
- screen:expect {
- grid = [[
- one^ |
- {s:one }{n:1info}{1: }|
- {n:two }{1: }|
- {n:looooooooooooooong }{1: }|
- {1:~ }|*6
- {2:-- }{5:match 1 of 3} |
- ]],
- }
- end
- -- delete one character make the pum width smaller than before
- -- info window position should be adjusted when popupmenu width changed
- feed('<BS>')
- if multigrid then
- screen:expect({
- grid = [[
- ## grid 1
- [2:----------------------------------------]|*10
- [3:----------------------------------------]|
- ## grid 2
- on^ |
- {1:~ }|*9
- ## grid 3
- {2:-- }{5:match 1 of 3} |
- ## grid 4
- {n:1info}|
- {n: }|
- ## grid 5
- {s:one }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 2, 1, 0, false, 100 },
- [4] = { 1001, 'NW', 1, 1, 15, false, 50 },
- },
- win_viewport = {
- [2] = {
- win = 1000,
- topline = 0,
- botline = 2,
- curline = 0,
- curcol = 2,
- linecount = 1,
- sum_scroll_delta = 0,
- },
- [4] = {
- win = 1001,
- topline = 0,
- botline = 2,
- curline = 0,
- curcol = 0,
- linecount = 1,
- sum_scroll_delta = 0,
- },
- },
- win_viewport_margins = {
- [2] = {
- bottom = 0,
- left = 0,
- right = 0,
- top = 0,
- win = 1000,
- },
- [4] = {
- bottom = 0,
- left = 0,
- right = 0,
- top = 0,
- win = 1001,
- },
- },
- })
- else
- screen:expect({
- grid = [[
- on^ |
- {s:one }{n:1info}{1: }|
- {1:~ }{n: }{1: }|
- {1:~ }|*7
- {2:-- }{5:match 1 of 3} |
- ]],
- })
- end
- -- when back to original the preview float should be closed.
- feed('<C-P>')
- if multigrid then
- screen:expect({
- grid = [[
- ## grid 1
- [2:----------------------------------------]|*10
- [3:----------------------------------------]|
- ## grid 2
- on^ |
- {1:~ }|*9
- ## grid 3
- {2:-- }{8:Back at original} |
- ## grid 5
- {n:one }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 2, 1, 0, false, 100 },
- },
- win_viewport = {
- [2] = {
- win = 1000,
- topline = 0,
- botline = 2,
- curline = 0,
- curcol = 2,
- linecount = 1,
- sum_scroll_delta = 0,
- },
- },
- win_viewport_margins = {
- [2] = {
- bottom = 0,
- left = 0,
- right = 0,
- top = 0,
- win = 1000,
- },
- },
- })
- else
- screen:expect({
- grid = [[
- on^ |
- {n:one }{1: }|
- {1:~ }|*8
- {2:-- }{8:Back at original} |
- ]],
- })
- end
- -- test nvim__complete_set_info
- feed('<ESC>S<C-X><C-O><C-N><C-N>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:----------------------------------------]|*10
- [3:----------------------------------------]|
- ## grid 2
- looooooooooooooong^ |
- {1:~ }|*9
- ## grid 3
- {2:-- }{5:match 3 of 3} |
- ## grid 5
- {n:one }|
- {n:two }|
- {s:looooooooooooooong }|
- ## grid 7
- {n:3info}|
- {n: }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 2, 1, 0, false, 100 },
- [7] = { 1003, 'NW', 1, 1, 19, false, 50 },
- },
- win_viewport = {
- [2] = {
- win = 1000,
- topline = 0,
- botline = 2,
- curline = 0,
- curcol = 18,
- linecount = 1,
- sum_scroll_delta = 0,
- },
- [7] = {
- win = 1003,
- topline = 0,
- botline = 2,
- curline = 0,
- curcol = 0,
- linecount = 1,
- sum_scroll_delta = 0,
- },
- },
- }
- else
- screen:expect {
- grid = [[
- looooooooooooooong^ |
- {n:one 3info}{1: }|
- {n:two }{1: }|
- {s:looooooooooooooong }{1: }|
- {1:~ }|*6
- {2:-- }{5:match 3 of 3} |
- ]],
- }
- end
- -- preview in left
- feed('<ESC>cc')
- insert(('test'):rep(5))
- feed('i<C-x><C-o>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:----------------------------------------]|*10
- [3:----------------------------------------]|
- ## grid 2
- itesttesttesttesttesone^t |
- {1:~ }|*9
- ## grid 3
- {2:-- }{5:match 1 of 3} |
- ## grid 5
- {s: one }|
- {n: two }|
- {n: looooooooooooooong }|
- ## grid 8
- {n:1info}|
- {n: }|
- ]],
- float_pos = {
- [8] = { 1004, 'NW', 1, 1, 14, false, 50 },
- [5] = { -1, 'NW', 2, 1, 19, false, 100 },
- },
- win_viewport = {
- [2] = {
- win = 1000,
- topline = 0,
- botline = 2,
- curline = 0,
- curcol = 23,
- linecount = 1,
- sum_scroll_delta = 0,
- },
- [8] = {
- win = 1004,
- topline = 0,
- botline = 2,
- curline = 0,
- curcol = 0,
- linecount = 1,
- sum_scroll_delta = 0,
- },
- },
- }
- else
- screen:expect {
- grid = [[
- itesttesttesttesttesone^t |
- {1:~ }{n:1info}{s: one }{1: }|
- {1:~ }{n: two }{1: }|
- {1:~ }{n: looooooooooooooong }{1: }|
- {1:~ }|*6
- {2:-- }{5:match 1 of 3} |
- ]],
- }
- end
- feed('<C-E><Esc>')
- -- works when scroll with treesitter highlight
- command('call TestTs()')
- feed('S<C-x><C-o>')
- if multigrid then
- screen:expect({
- grid = [[
- ## grid 1
- [2:----------------------------------------]|*10
- [3:----------------------------------------]|
- ## grid 2
- one^ |
- {1:~ }|*9
- ## grid 3
- {2:-- }{5:match 1 of 3} |
- ## grid 5
- {s:one }|
- {n:two }|
- {n:looooooooooooooong }|
- ## grid 9
- {n:```lua }|
- {n:function test()}|
- {n: print('foo') }|
- {n:end }|
- {n:``` }|
- {n: }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 2, 1, 0, false, 100 },
- [9] = { 1005, 'NW', 1, 1, 19, false, 50 },
- },
- win_viewport = {
- [2] = {
- win = 1000,
- topline = 0,
- botline = 2,
- curline = 0,
- curcol = 3,
- linecount = 1,
- sum_scroll_delta = 0,
- },
- [9] = {
- win = 1005,
- topline = 0,
- botline = 6,
- curline = 0,
- curcol = 0,
- linecount = 5,
- sum_scroll_delta = 0,
- },
- },
- win_viewport_margins = {
- [2] = {
- bottom = 0,
- left = 0,
- right = 0,
- top = 0,
- win = 1000,
- },
- [9] = {
- bottom = 0,
- left = 0,
- right = 0,
- top = 0,
- win = 1005,
- },
- },
- })
- else
- screen:expect({
- grid = [[
- one^ |
- {s:one }{n:```lua }{1: }|
- {n:two function test()}{1: }|
- {n:looooooooooooooong print('foo') }{1: }|
- {1:~ }{n:end }{1: }|
- {1:~ }{n:``` }{1: }|
- {1:~ }{n: }{1: }|
- {1:~ }|*3
- {2:-- }{5:match 1 of 3} |
- ]],
- })
- end
- end)
- end)
- it('with vsplits', function()
- screen:try_resize(32, 8)
- insert('aaa aab aac\n')
- feed(':vsplit<cr>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [4:--------------------]│[2:-----------]|*6
- {4:[No Name] [+] }{3:<Name] [+] }|
- [3:--------------------------------]|
- ## grid 2
- aaa aab aac|
- |
- {1:~ }|*4
- ## grid 3
- :vsplit |
- ## grid 4
- aaa aab aac |
- ^ |
- {1:~ }|*4
- ]],
- }
- else
- screen:expect([[
- aaa aab aac │aaa aab aac|
- ^ │ |
- {1:~ }│{1:~ }|*4
- {4:[No Name] [+] }{3:<Name] [+] }|
- :vsplit |
- ]])
- end
- feed('ibbb a<c-x><c-n>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [4:--------------------]│[2:-----------]|*6
- {4:[No Name] [+] }{3:<Name] [+] }|
- [3:--------------------------------]|
- ## grid 2
- aaa aab aac|
- bbb aaa |
- {1:~ }|*4
- ## grid 3
- {2:-- }{5:match 1 of 3} |
- ## grid 4
- aaa aab aac |
- bbb aaa^ |
- {1:~ }|*4
- ## grid 5
- {s: aaa }|
- {n: aab }|
- {n: aac }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 4, 2, 3, false, 100 },
- },
- }
- else
- screen:expect([[
- aaa aab aac │aaa aab aac|
- bbb aaa^ │bbb aaa |
- {1:~ }{s: aaa }{1: }│{1:~ }|
- {1:~ }{n: aab }{1: }│{1:~ }|
- {1:~ }{n: aac }{1: }│{1:~ }|
- {1:~ }│{1:~ }|
- {4:[No Name] [+] }{3:<Name] [+] }|
- {2:-- }{5:match 1 of 3} |
- ]])
- end
- feed('<esc><c-w><c-w>oc a<c-x><c-n>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [4:-----------]│[2:--------------------]|*6
- {3:<Name] [+] }{4:[No Name] [+] }|
- [3:--------------------------------]|
- ## grid 2
- aaa aab aac |
- bbb aaa |
- c aaa^ |
- {1:~ }|*3
- ## grid 3
- {2:-- }{5:match 1 of 3} |
- ## grid 4
- aaa aab aac|
- bbb aaa |
- c aaa |
- {1:~ }|*3
- ## grid 5
- {s: aaa }|
- {n: aab }|
- {n: aac }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 2, 3, 1, false, 100 },
- },
- }
- else
- screen:expect([[
- aaa aab aac│aaa aab aac |
- bbb aaa │bbb aaa |
- c aaa │c aaa^ |
- {1:~ }│{1:~}{s: aaa }{1: }|
- {1:~ }│{1:~}{n: aab }{1: }|
- {1:~ }│{1:~}{n: aac }{1: }|
- {3:<Name] [+] }{4:[No Name] [+] }|
- {2:-- }{5:match 1 of 3} |
- ]])
- end
- feed('bcdef ccc a<c-x><c-n>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [4:-----------]│[2:--------------------]|*6
- {3:<Name] [+] }{4:[No Name] [+] }|
- [3:--------------------------------]|
- ## grid 2
- aaa aab aac |
- bbb aaa |
- c aaabcdef ccc aaa^ |
- {1:~ }|*3
- ## grid 3
- {2:-- }{5:match 1 of 4} |
- ## grid 4
- aaa aab aac|
- bbb aaa |
- c aaabcdef |
- ccc aaa |
- {1:~ }|*2
- ## grid 5
- {s: aaa }|
- {n: aab }|
- {n: aac }|
- {n: aaabcdef}|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 2, 3, 11, false, 100 },
- },
- }
- else
- screen:expect([[
- aaa aab aac│aaa aab aac |
- bbb aaa │bbb aaa |
- c aaabcdef │c aaabcdef ccc aaa^ |
- ccc aaa │{1:~ }{s: aaa }|
- {1:~ }│{1:~ }{n: aab }|
- {1:~ }│{1:~ }{n: aac }|
- {3:<Name] [+] }{4:[No Name] [}{n: aaabcdef}|
- {2:-- }{5:match 1 of 4} |
- ]])
- end
- feed('\n<c-x><c-n>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [4:-----------]│[2:--------------------]|*6
- {3:<Name] [+] }{4:[No Name] [+] }|
- [3:--------------------------------]|
- ## grid 2
- aaa aab aac |
- bbb aaa |
- c aaabcdef ccc aaa |
- aaa^ |
- {1:~ }|*2
- ## grid 3
- {2:-- }{5:match 1 of 6} |
- ## grid 4
- aaa aab aac|
- bbb aaa |
- c aaabcdef |
- ccc aaa |
- aaa |
- {1:~ }|
- ## grid 5
- {s: aaa }{c: }|
- {n: aab }{s: }|
- {n: aac }{s: }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 2, 4, -1, false, 100 },
- },
- }
- else
- screen:expect([[
- aaa aab aac│aaa aab aac |
- bbb aaa │bbb aaa |
- c aaabcdef │c aaabcdef ccc aaa |
- ccc aaa │aaa^ |
- aaa {s: aaa }{c: }{1: }|
- {1:~ }{n: aab }{s: }{1: }|
- {3:<Name] [+] }{n: aac }{s: }{4: }|
- {2:-- }{5:match 1 of 6} |
- ]])
- end
- end)
- if not multigrid then
- it('with split and scroll', function()
- screen:try_resize(60, 14)
- command('split')
- command('set completeopt+=noinsert')
- command('set mouse=a')
- insert([[
- Lorem ipsum dolor sit amet, consectetur
- adipisicing elit, sed do eiusmod tempor
- incididunt ut labore et dolore magna aliqua.
- Ut enim ad minim veniam, quis nostrud
- exercitation ullamco laboris nisi ut aliquip ex
- ea commodo consequat. Duis aute irure dolor in
- reprehenderit in voluptate velit esse cillum
- dolore eu fugiat nulla pariatur. Excepteur sint
- occaecat cupidatat non proident, sunt in culpa
- qui officia deserunt mollit anim id est
- laborum.
- ]])
- screen:expect([[
- reprehenderit in voluptate velit esse cillum |
- dolore eu fugiat nulla pariatur. Excepteur sint |
- occaecat cupidatat non proident, sunt in culpa |
- qui officia deserunt mollit anim id est |
- laborum. |
- ^ |
- {4:[No Name] [+] }|
- Lorem ipsum dolor sit amet, consectetur |
- adipisicing elit, sed do eiusmod tempor |
- incididunt ut labore et dolore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- exercitation ullamco laboris nisi ut aliquip ex |
- {3:[No Name] [+] }|
- |
- ]])
- feed('ggOEst <c-x><c-p>')
- screen:expect([[
- Est ^ |
- L{n: sunt }{s: }sit amet, consectetur |
- a{n: in }{s: }sed do eiusmod tempor |
- i{n: culpa }{s: }re et dolore magna aliqua. |
- U{n: qui }{s: }eniam, quis nostrud |
- e{n: officia }{s: }co laboris nisi ut aliquip ex |
- {4:[No}{n: deserunt }{s: }{4: }|
- Est{n: mollit }{s: } |
- L{n: anim }{s: }sit amet, consectetur |
- a{n: id }{s: }sed do eiusmod tempor |
- i{n: est }{s: }re et dolore magna aliqua. |
- U{n: laborum }{c: }eniam, quis nostrud |
- {3:[No}{s: Est }{c: }{3: }|
- {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
- ]])
- api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
- screen:expect([[
- Est ^ |
- L{n: sunt }{s: }sit amet, consectetur |
- a{n: in }{s: }sed do eiusmod tempor |
- i{n: culpa }{s: }re et dolore magna aliqua. |
- U{n: qui }{s: }eniam, quis nostrud |
- e{n: officia }{s: }co laboris nisi ut aliquip ex |
- {4:[No}{n: deserunt }{s: }{4: }|
- i{n: mollit }{s: }re et dolore magna aliqua. |
- U{n: anim }{s: }eniam, quis nostrud |
- e{n: id }{s: }co laboris nisi ut aliquip ex |
- e{n: est }{s: }at. Duis aute irure dolor in |
- r{n: laborum }{c: }oluptate velit esse cillum |
- {3:[No}{s: Est }{c: }{3: }|
- {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
- ]])
- feed('e')
- screen:expect([[
- Est e^ |
- L{n: elit } sit amet, consectetur |
- a{n: eiusmod } sed do eiusmod tempor |
- i{n: et }ore et dolore magna aliqua. |
- U{n: enim }veniam, quis nostrud |
- e{n: exercitation }mco laboris nisi ut aliquip ex |
- {4:[No}{n: ex }{4: }|
- i{n: ea }ore et dolore magna aliqua. |
- U{n: esse }veniam, quis nostrud |
- e{n: eu }mco laboris nisi ut aliquip ex |
- e{s: est }uat. Duis aute irure dolor in |
- reprehenderit in voluptate velit esse cillum |
- {3:[No Name] [+] }|
- {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
- ]])
- api.nvim_input_mouse('wheel', 'up', '', 0, 9, 40)
- screen:expect([[
- Est e^ |
- L{n: elit } sit amet, consectetur |
- a{n: eiusmod } sed do eiusmod tempor |
- i{n: et }ore et dolore magna aliqua. |
- U{n: enim }veniam, quis nostrud |
- e{n: exercitation }mco laboris nisi ut aliquip ex |
- {4:[No}{n: ex }{4: }|
- Est{n: ea } |
- L{n: esse } sit amet, consectetur |
- a{n: eu } sed do eiusmod tempor |
- i{s: est }ore et dolore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- {3:[No Name] [+] }|
- {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
- ]])
- feed('s')
- screen:expect([[
- Est es^ |
- L{n: esse } sit amet, consectetur |
- a{s: est } sed do eiusmod tempor |
- incididunt ut labore et dolore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- exercitation ullamco laboris nisi ut aliquip ex |
- {4:[No Name] [+] }|
- Est es |
- Lorem ipsum dolor sit amet, consectetur |
- adipisicing elit, sed do eiusmod tempor |
- incididunt ut labore et dolore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- {3:[No Name] [+] }|
- {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
- ]])
- api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
- screen:expect([[
- Est es^ |
- L{n: esse } sit amet, consectetur |
- a{s: est } sed do eiusmod tempor |
- incididunt ut labore et dolore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- exercitation ullamco laboris nisi ut aliquip ex |
- {4:[No Name] [+] }|
- incididunt ut labore et dolore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- exercitation ullamco laboris nisi ut aliquip ex |
- ea commodo consequat. Duis aute irure dolor in |
- reprehenderit in voluptate velit esse cillum |
- {3:[No Name] [+] }|
- {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
- ]])
- feed('<bs>')
- screen:expect([[
- Est e^ |
- L{n: elit } sit amet, consectetur |
- a{n: eiusmod } sed do eiusmod tempor |
- i{n: et }ore et dolore magna aliqua. |
- U{n: enim }veniam, quis nostrud |
- e{n: exercitation }mco laboris nisi ut aliquip ex |
- {4:[No}{n: ex }{4: }|
- i{n: ea }ore et dolore magna aliqua. |
- U{n: esse }veniam, quis nostrud |
- e{n: eu }mco laboris nisi ut aliquip ex |
- e{s: est }uat. Duis aute irure dolor in |
- reprehenderit in voluptate velit esse cillum |
- {3:[No Name] [+] }|
- {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} |
- ]])
- feed('<c-p>')
- screen:expect([[
- Est eu^ |
- L{n: elit } sit amet, consectetur |
- a{n: eiusmod } sed do eiusmod tempor |
- i{n: et }ore et dolore magna aliqua. |
- U{n: enim }veniam, quis nostrud |
- e{n: exercitation }mco laboris nisi ut aliquip ex |
- {4:[No}{n: ex }{4: }|
- i{n: ea }ore et dolore magna aliqua. |
- U{n: esse }veniam, quis nostrud |
- e{s: eu }mco laboris nisi ut aliquip ex |
- e{n: est }uat. Duis aute irure dolor in |
- reprehenderit in voluptate velit esse cillum |
- {3:[No Name] [+] }|
- {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} |
- ]])
- api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40)
- screen:expect([[
- Est eu^ |
- L{n: elit } sit amet, consectetur |
- a{n: eiusmod } sed do eiusmod tempor |
- i{n: et }ore et dolore magna aliqua. |
- U{n: enim }veniam, quis nostrud |
- e{n: exercitation }mco laboris nisi ut aliquip ex |
- {4:[No}{n: ex }{4: }|
- e{n: ea }uat. Duis aute irure dolor in |
- r{n: esse }voluptate velit esse cillum |
- d{s: eu }nulla pariatur. Excepteur sint |
- o{n: est }t non proident, sunt in culpa |
- qui officia deserunt mollit anim id est |
- {3:[No Name] [+] }|
- {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} |
- ]])
- fn.complete(4, { 'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' })
- screen:expect([[
- Est eu^ |
- {s: ea }t amet, consectetur |
- {n: eeeeeeeeeeeeeeeeee }d do eiusmod tempor |
- {n: ei } et dolore magna aliqua. |
- {n: eo }iam, quis nostrud |
- {n: eu } laboris nisi ut aliquip ex |
- {4:[N}{n: ey }{4: }|
- {n: eå }. Duis aute irure dolor in |
- {n: eä }uptate velit esse cillum |
- {n: eö }la pariatur. Excepteur sint |
- occaecat cupidatat non proident, sunt in culpa |
- qui officia deserunt mollit anim id est |
- {3:[No Name] [+] }|
- {2:-- Keyword Local completion (^N^P) }{5:match 1 of 9} |
- ]])
- fn.complete(4, { 'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' })
- screen:expect([[
- Est eu^ |
- {s: ea }r sit amet, consectetur |
- {n: eee }, sed do eiusmod tempor |
- {n: ei }bore et dolore magna aliqua. |
- {n: eo } veniam, quis nostrud |
- {n: eu }amco laboris nisi ut aliquip ex |
- {4:[N}{n: ey }{4: }|
- {n: eå }quat. Duis aute irure dolor in |
- {n: eä } voluptate velit esse cillum |
- {n: eö } nulla pariatur. Excepteur sint |
- occaecat cupidatat non proident, sunt in culpa |
- qui officia deserunt mollit anim id est |
- {3:[No Name] [+] }|
- {2:-- INSERT --} |
- ]])
- feed('<c-n>')
- screen:expect([[
- Esteee^ |
- {n: ea }r sit amet, consectetur |
- {s: eee }, sed do eiusmod tempor |
- {n: ei }bore et dolore magna aliqua. |
- {n: eo } veniam, quis nostrud |
- {n: eu }amco laboris nisi ut aliquip ex |
- {4:[N}{n: ey }{4: }|
- {n: eå }quat. Duis aute irure dolor in |
- {n: eä } voluptate velit esse cillum |
- {n: eö } nulla pariatur. Excepteur sint |
- occaecat cupidatat non proident, sunt in culpa |
- qui officia deserunt mollit anim id est |
- {3:[No Name] [+] }|
- {2:-- INSERT --} |
- ]])
- fn.complete(6, { 'foo', 'bar' })
- screen:expect([[
- Esteee^ |
- Lo{s: foo }sit amet, consectetur |
- ad{n: bar }sed do eiusmod tempor |
- incididunt ut labore et dolore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- exercitation ullamco laboris nisi ut aliquip ex |
- {4:[No Name] [+] }|
- ea commodo consequat. Duis aute irure dolor in |
- reprehenderit in voluptate velit esse cillum |
- dolore eu fugiat nulla pariatur. Excepteur sint |
- occaecat cupidatat non proident, sunt in culpa |
- qui officia deserunt mollit anim id est |
- {3:[No Name] [+] }|
- {2:-- INSERT --} |
- ]])
- feed('<c-y>')
- screen:expect([[
- Esteefoo^ |
- Lorem ipsum dolor sit amet, consectetur |
- adipisicing elit, sed do eiusmod tempor |
- incididunt ut labore et dolore magna aliqua. |
- Ut enim ad minim veniam, quis nostrud |
- exercitation ullamco laboris nisi ut aliquip ex |
- {4:[No Name] [+] }|
- ea commodo consequat. Duis aute irure dolor in |
- reprehenderit in voluptate velit esse cillum |
- dolore eu fugiat nulla pariatur. Excepteur sint |
- occaecat cupidatat non proident, sunt in culpa |
- qui officia deserunt mollit anim id est |
- {3:[No Name] [+] }|
- {2:-- INSERT --} |
- ]])
- end)
- it('can be moved due to wrap or resize', function()
- feed('isome long prefix before the ')
- command('set completeopt+=noinsert,noselect')
- command('set linebreak')
- fn.complete(29, { 'word', 'choice', 'text', 'thing' })
- screen:expect([[
- some long prefix before the ^ |
- {1:~ }{n: word }|
- {1:~ }{n: choice}|
- {1:~ }{n: text }|
- {1:~ }{n: thing }|
- {1:~ }|*14
- {2:-- INSERT --} |
- ]])
- feed('<c-p>')
- screen:expect([[
- some long prefix before the |
- thing^ |
- {n:word }{1: }|
- {n:choice }{1: }|
- {n:text }{1: }|
- {s:thing }{1: }|
- {1:~ }|*13
- {2:-- INSERT --} |
- ]])
- feed('<c-p>')
- screen:expect([[
- some long prefix before the text|
- {1:^~ }{n: word }|
- {1:~ }{n: choice}|
- {1:~ }{s: text }|
- {1:~ }{n: thing }|
- {1:~ }|*14
- {2:-- INSERT --} |
- ]])
- screen:try_resize(30, 8)
- screen:expect([[
- some long prefix before the |
- text^ |
- {n:word }{1: }|
- {n:choice }{1: }|
- {s:text }{1: }|
- {n:thing }{1: }|
- {1:~ }|
- {2:-- INSERT --} |
- ]])
- screen:try_resize(50, 8)
- screen:expect([[
- some long prefix before the text^ |
- {1:~ }{n: word }{1: }|
- {1:~ }{n: choice }{1: }|
- {1:~ }{s: text }{1: }|
- {1:~ }{n: thing }{1: }|
- {1:~ }|*2
- {2:-- INSERT --} |
- ]])
- screen:try_resize(25, 10)
- screen:expect([[
- some long prefix before |
- the text^ |
- {1:~ }{n: word }{1: }|
- {1:~ }{n: choice }{1: }|
- {1:~ }{s: text }{1: }|
- {1:~ }{n: thing }{1: }|
- {1:~ }|*3
- {2:-- INSERT --} |
- ]])
- screen:try_resize(12, 5)
- screen:expect([[
- some long |
- prefix |
- bef{n: word } |
- tex{n: }^ |
- {2:-- INSERT --}|
- ]])
- -- can't draw the pum, but check we don't crash
- screen:try_resize(12, 2)
- screen:expect([[
- {1:<<<}t^ |
- {2:-- INSERT --}|
- ]])
- -- but state is preserved, pum reappears
- screen:try_resize(20, 8)
- screen:expect([[
- some long prefix |
- before the text^ |
- {1:~ }{n: word }{1: }|
- {1:~ }{n: choice }{1: }|
- {1:~ }{s: text }{1: }|
- {1:~ }{n: thing }{1: }|
- {1:~ }|
- {2:-- INSERT --} |
- ]])
- end)
- it('with VimResized autocmd', function()
- feed('isome long prefix before the ')
- command('set completeopt+=noinsert,noselect')
- command('autocmd VimResized * redraw!')
- command('set linebreak')
- fn.complete(29, { 'word', 'choice', 'text', 'thing' })
- screen:expect([[
- some long prefix before the ^ |
- {1:~ }{n: word }|
- {1:~ }{n: choice}|
- {1:~ }{n: text }|
- {1:~ }{n: thing }|
- {1:~ }|*14
- {2:-- INSERT --} |
- ]])
- screen:try_resize(16, 10)
- screen:expect([[
- some long |
- prefix before |
- the ^ |
- {1:~ }{n: word }|
- {1:~ }{n: choice }|
- {1:~ }{n: text }|
- {1:~ }{n: thing }|
- {1:~ }|*2
- {2:-- INSERT --} |
- ]])
- end)
- it('with rightleft window', function()
- command('set rl wildoptions+=pum')
- feed('isome rightleft ')
- screen:expect([[
- ^ tfelthgir emos|
- {1: ~}|*18
- {2:-- INSERT --} |
- ]])
- command('set completeopt+=noinsert,noselect')
- fn.complete(16, { 'word', 'choice', 'text', 'thing' })
- screen:expect([[
- ^ tfelthgir emos|
- {1: }{n: drow }{1: ~}|
- {1: }{n: eciohc }{1: ~}|
- {1: }{n: txet }{1: ~}|
- {1: }{n: gniht }{1: ~}|
- {1: ~}|*14
- {2:-- INSERT --} |
- ]])
- feed('<c-n>')
- screen:expect([[
- ^ drow tfelthgir emos|
- {1: }{s: drow }{1: ~}|
- {1: }{n: eciohc }{1: ~}|
- {1: }{n: txet }{1: ~}|
- {1: }{n: gniht }{1: ~}|
- {1: ~}|*14
- {2:-- INSERT --} |
- ]])
- feed('<c-y>')
- screen:expect([[
- ^ drow tfelthgir emos|
- {1: ~}|*18
- {2:-- INSERT --} |
- ]])
- -- not rightleft on the cmdline
- feed('<esc>:sign ')
- screen:expect {
- grid = [[
- drow tfelthgir emos|
- {1: ~}|*18
- :sign ^ |
- ]],
- }
- -- oldtest: Test_wildmenu_pum_rightleft()
- feed('<tab>')
- screen:expect {
- grid = [[
- drow tfelthgir emos|
- {1: ~}|*12
- {1: }{s: define }{1: ~}|
- {1: }{n: jump }{1: ~}|
- {1: }{n: list }{1: ~}|
- {1: }{n: place }{1: ~}|
- {1: }{n: undefine }{1: ~}|
- {1: }{n: unplace }{1: ~}|
- :sign define^ |
- ]],
- }
- end)
- end
- it('with rightleft vsplits', function()
- screen:try_resize(40, 6)
- command('set rightleft')
- command('rightbelow vsplit')
- command('set completeopt+=noinsert,noselect')
- command('set pumheight=2')
- feed('isome rightleft ')
- fn.complete(16, { 'word', 'choice', 'text', 'thing' })
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:-------------------]│[4:--------------------]|*4
- {3:[No Name] [+] }{4:[No Name] [+] }|
- [3:----------------------------------------]|
- ## grid 2
- tfelthgir emos|
- {1: ~}|*3
- ## grid 3
- {2:-- INSERT --} |
- ## grid 4
- ^ tfelthgir emos|
- {1: ~}|*3
- ## grid 5
- {c: }{n: drow }|
- {s: }{n: eciohc }|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 4, 1, -11, false, 100 },
- },
- }
- else
- screen:expect([[
- tfelthgir emos│ ^ tfelthgir emos|
- {1: }{c: }{n: drow }{1: ~}|
- {1: }{s: }{n: eciohc }{1: ~}|
- {1: ~}│{1: ~}|
- {3:[No Name] [+] }{4:[No Name] [+] }|
- {2:-- INSERT --} |
- ]])
- end
- feed('<C-E><CR>')
- fn.complete(1, { 'word', 'choice', 'text', 'thing' })
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:-------------------]│[4:--------------------]|*4
- {3:[No Name] [+] }{4:[No Name] [+] }|
- [3:----------------------------------------]|
- ## grid 2
- tfelthgir emos|
- |
- {1: ~}|*2
- ## grid 3
- {2:-- INSERT --} |
- ## grid 4
- tfelthgir emos|
- ^ |
- {1: ~}|*2
- ## grid 5
- {c: }{n: drow}|
- {s: }{n: eciohc}|
- ]],
- float_pos = {
- [5] = { -1, 'NW', 4, 2, 4, false, 100 },
- },
- }
- else
- screen:expect([[
- tfelthgir emos│ tfelthgir emos|
- │ ^ |
- {1: ~}│{1: }{c: }{n: drow}|
- {1: ~}│{1: }{s: }{n: eciohc}|
- {3:[No Name] [+] }{4:[No Name] [+] }|
- {2:-- INSERT --} |
- ]])
- end
- feed('<C-E>')
- async_meths.nvim_call_function('input', { '', '', 'sign' })
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:-------------------]│[4:--------------------]|*4
- {3:[No Name] [+] }{4:[No Name] [+] }|
- [3:----------------------------------------]|
- ## grid 2
- tfelthgir emos|
- |
- {1: ~}|*2
- ## grid 3
- ^ |
- ## grid 4
- tfelthgir emos|
- |
- {1: ~}|*2
- ]],
- }
- else
- screen:expect([[
- tfelthgir emos│ tfelthgir emos|
- │ |
- {1: ~}│{1: ~}|*2
- {3:[No Name] [+] }{4:[No Name] [+] }|
- ^ |
- ]])
- end
- command('set wildoptions+=pum')
- feed('<Tab>')
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:-------------------]│[4:--------------------]|*4
- {3:[No Name] [+] }{4:[No Name] [+] }|
- [3:----------------------------------------]|
- ## grid 2
- tfelthgir emos|
- |
- {1: ~}|*2
- ## grid 3
- define^ |
- ## grid 4
- tfelthgir emos|
- |
- {1: ~}|*2
- ## grid 5
- {s:define }{c: }|
- {n:jump }{s: }|
- ]],
- float_pos = {
- [5] = { -1, 'SW', 1, 5, 0, false, 250 },
- },
- }
- else
- screen:expect([[
- tfelthgir emos│ tfelthgir emos|
- │ |
- {1: ~}│{1: ~}|
- {s:define }{c: }{1: ~}│{1: ~}|
- {n:jump }{s: }{3: }{4:[No Name] [+] }|
- define^ |
- ]])
- end
- end)
- if not multigrid then
- it('with multiline messages', function()
- screen:try_resize(40, 8)
- feed('ixx<cr>')
- command('imap <f2> <cmd>echoerr "very"\\|echoerr "much"\\|echoerr "error"<cr>')
- fn.complete(1, { 'word', 'choice', 'text', 'thing' })
- screen:expect([[
- xx |
- word^ |
- {s:word }{1: }|
- {n:choice }{1: }|
- {n:text }{1: }|
- {n:thing }{1: }|
- {1:~ }|
- {2:-- INSERT --} |
- ]])
- feed('<f2>')
- screen:expect([[
- xx |
- word |
- {s:word }{1: }|
- {4: }|
- {6:very} |
- {6:much} |
- {6:error} |
- {5:Press ENTER or type command to continue}^ |
- ]])
- feed('<cr>')
- screen:expect([[
- xx |
- word^ |
- {s:word }{1: }|
- {n:choice }{1: }|
- {n:text }{1: }|
- {n:thing }{1: }|
- {1:~ }|
- {2:-- INSERT --} |
- ]])
- feed('<c-n>')
- screen:expect([[
- xx |
- choice^ |
- {n:word }{1: }|
- {s:choice }{1: }|
- {n:text }{1: }|
- {n:thing }{1: }|
- {1:~ }|
- {2:-- INSERT --} |
- ]])
- command('split')
- screen:expect([[
- xx |
- choice^ |
- {n:word }{1: }|
- {s:choice }{4: }|
- {n:text } |
- {n:thing } |
- {3:[No Name] [+] }|
- {2:-- INSERT --} |
- ]])
- api.nvim_input_mouse('wheel', 'down', '', 0, 6, 15)
- screen:expect {
- grid = [[
- xx |
- choice^ |
- {n:word }{1: }|
- {s:choice }{4: }|
- {n:text } |
- {n:thing }{1: }|
- {3:[No Name] [+] }|
- {2:-- INSERT --} |
- ]],
- unchanged = true,
- }
- end)
- it('with kind, menu and abbr attributes', function()
- screen:try_resize(40, 8)
- feed('ixx ')
- fn.complete(4, {
- { word = 'wordey', kind = 'x', menu = 'extrainfo' },
- 'thing',
- { word = 'secret', abbr = 'sneaky', menu = 'bar' },
- })
- screen:expect([[
- xx wordey^ |
- {1:~ }{s: wordey x extrainfo }{1: }|
- {1:~ }{n: thing }{1: }|
- {1:~ }{n: sneaky bar }{1: }|
- {1:~ }|*3
- {2:-- INSERT --} |
- ]])
- feed('<c-p>')
- screen:expect([[
- xx ^ |
- {1:~ }{n: wordey x extrainfo }{1: }|
- {1:~ }{n: thing }{1: }|
- {1:~ }{n: sneaky bar }{1: }|
- {1:~ }|*3
- {2:-- INSERT --} |
- ]])
- feed('<c-p>')
- screen:expect([[
- xx secret^ |
- {1:~ }{n: wordey x extrainfo }{1: }|
- {1:~ }{n: thing }{1: }|
- {1:~ }{s: sneaky bar }{1: }|
- {1:~ }|*3
- {2:-- INSERT --} |
- ]])
- feed('<esc>')
- screen:expect([[
- xx secre^t |
- {1:~ }|*6
- |
- ]])
- end)
- it('wildoptions=pum', function()
- screen:try_resize(32, 10)
- command('set wildmenu')
- command('set wildoptions=pum')
- command('set shellslash')
- command('cd test/functional/fixtures/wildpum')
- feed(':sign ')
- screen:expect([[
- |
- {1:~ }|*8
- :sign ^ |
- ]])
- feed('<Tab>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{s: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign define^ |
- ]])
- feed('<Right><Right>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{s: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign list^ |
- ]])
- feed('<C-N>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{s: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign place^ |
- ]])
- feed('<C-P>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{s: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign list^ |
- ]])
- feed('<Left>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{s: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign jump^ |
- ]])
- -- pressing <C-E> should end completion and go back to the original match
- feed('<C-E>')
- screen:expect([[
- |
- {1:~ }|*8
- :sign ^ |
- ]])
- -- pressing <C-Y> should select the current match and end completion
- feed('<Tab><C-P><C-P><C-Y>')
- screen:expect([[
- |
- {1:~ }|*8
- :sign unplace^ |
- ]])
- -- showing popup menu in different columns in the cmdline
- feed('<C-U>sign define <Tab>')
- screen:expect([[
- |
- {1:~ }|
- {1:~ }{s: culhl= }{1: }|
- {1:~ }{n: icon= }{1: }|
- {1:~ }{n: linehl= }{1: }|
- {1:~ }{n: numhl= }{1: }|
- {1:~ }{n: priority= }{1: }|
- {1:~ }{n: text= }{1: }|
- {1:~ }{n: texthl= }{1: }|
- :sign define culhl=^ |
- ]])
- feed('<Space><Tab>')
- screen:expect([[
- |
- {1:~ }|
- {1:~ }{s: culhl= }{1: }|
- {1:~ }{n: icon= }{1: }|
- {1:~ }{n: linehl= }{1: }|
- {1:~ }{n: numhl= }{1: }|
- {1:~ }{n: priority= }{1: }|
- {1:~ }{n: text= }{1: }|
- {1:~ }{n: texthl= }{1: }|
- :sign define culhl= culhl=^ |
- ]])
- feed('<C-U>e Xnamedi<Tab><Tab>')
- screen:expect([[
- |
- {1:~ }|*6
- {1:~ }{s: XdirA/ }{1: }|
- {1:~ }{n: XfileA }{1: }|
- :e Xnamedir/XdirA/^ |
- ]])
- -- Pressing <Down> on a directory name should go into that directory
- feed('<Down>')
- screen:expect([[
- |
- {1:~ }|*6
- {1:~ }{s: XdirB/ }{1: }|
- {1:~ }{n: XfileB }{1: }|
- :e Xnamedir/XdirA/XdirB/^ |
- ]])
- -- Pressing <Up> on a directory name should go to the parent directory
- feed('<Up>')
- screen:expect([[
- |
- {1:~ }|*6
- {1:~ }{s: XdirA/ }{1: }|
- {1:~ }{n: XfileA }{1: }|
- :e Xnamedir/XdirA/^ |
- ]])
- -- Pressing <C-A> when the popup menu is displayed should list all the
- -- matches and remove the popup menu
- feed(':<C-U>sign <Tab><C-A>')
- screen:expect([[
- |
- {1:~ }|*6
- {4: }|
- :sign define jump list place und|
- efine unplace^ |
- ]])
- -- Pressing <Left> after that should move the cursor
- feed('<Left>')
- screen:expect([[
- |
- {1:~ }|*6
- {4: }|
- :sign define jump list place und|
- efine unplac^e |
- ]])
- feed('<End>')
- -- Pressing <C-D> when the popup menu is displayed should remove the popup
- -- menu
- feed('<C-U>sign <Tab><C-D>')
- screen:expect([[
- |
- {1:~ }|*5
- {4: }|
- :sign define |
- define |
- :sign define^ |
- ]])
- -- Pressing <S-Tab> should open the popup menu with the last entry selected
- feed('<C-U><CR>:sign <S-Tab><C-P>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{s: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign undefine^ |
- ]])
- -- Pressing <Esc> should close the popup menu and cancel the cmd line
- feed('<C-U><CR>:sign <Tab><Esc>')
- screen:expect([[
- ^ |
- {1:~ }|*8
- |
- ]])
- -- Typing a character when the popup is open, should close the popup
- feed(':sign <Tab>x')
- screen:expect([[
- |
- {1:~ }|*8
- :sign definex^ |
- ]])
- -- When the popup is open, entering the cmdline window should close the popup
- feed('<C-U>sign <Tab><C-F>')
- screen:expect([[
- |
- {3:[No Name] }|
- {1::}sign define |
- {1::}sign define^ |
- {1:~ }|*4
- {4:[Command Line] }|
- :sign define |
- ]])
- feed(':q<CR>')
- -- After the last popup menu item, <C-N> should show the original string
- feed(':sign u<Tab><C-N><C-N>')
- screen:expect([[
- |
- {1:~ }|*6
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign u^ |
- ]])
- -- Use the popup menu for the command name
- feed('<C-U>bu<Tab>')
- screen:expect([[
- |
- {1:~ }|*4
- {s: bufdo }{1: }|
- {n: buffer }{1: }|
- {n: buffers }{1: }|
- {n: bunload }{1: }|
- :bufdo^ |
- ]])
- -- Pressing <BS> should remove the popup menu and erase the last character
- feed('<C-E><C-U>sign <Tab><BS>')
- screen:expect([[
- |
- {1:~ }|*8
- :sign defin^ |
- ]])
- -- Pressing <C-W> should remove the popup menu and erase the previous word
- feed('<C-E><C-U>sign <Tab><C-W>')
- screen:expect([[
- |
- {1:~ }|*8
- :sign ^ |
- ]])
- -- Pressing <C-U> should remove the popup menu and erase the entire line
- feed('<C-E><C-U>sign <Tab><C-U>')
- screen:expect([[
- |
- {1:~ }|*8
- :^ |
- ]])
- -- Using <C-E> to cancel the popup menu and then pressing <Up> should recall
- -- the cmdline from history
- feed('sign xyz<Esc>:sign <Tab><C-E><Up>')
- screen:expect([[
- |
- {1:~ }|*8
- :sign xyz^ |
- ]])
- feed('<esc>')
- -- Check "list" still works
- command('set wildmode=longest,list')
- feed(':cn<Tab>')
- screen:expect([[
- |
- {1:~ }|*3
- {4: }|
- :cn |
- cnewer cnoreabbrev |
- cnext cnoremap |
- cnfile cnoremenu |
- :cn^ |
- ]])
- feed('s')
- screen:expect([[
- |
- {1:~ }|*3
- {4: }|
- :cn |
- cnewer cnoreabbrev |
- cnext cnoremap |
- cnfile cnoremenu |
- :cns^ |
- ]])
- feed('<esc>')
- command('set wildmode=full')
- -- Tests a directory name contained full-width characters.
- feed(':e あいう/<Tab>')
- screen:expect([[
- |
- {1:~ }|*5
- {1:~ }{s: 123 }{1: }|
- {1:~ }{n: abc }{1: }|
- {1:~ }{n: xyz }{1: }|
- :e あいう/123^ |
- ]])
- feed('<Esc>')
- -- Pressing <PageDown> should scroll the menu downward
- feed(':sign <Tab><PageDown>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{s: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign undefine^ |
- ]])
- feed('<PageDown>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{s: unplace }{1: }|
- :sign unplace^ |
- ]])
- feed('<PageDown>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign ^ |
- ]])
- feed('<PageDown>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{s: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign define^ |
- ]])
- feed('<C-U>sign <Tab><Right><Right><PageDown>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{s: unplace }{1: }|
- :sign unplace^ |
- ]])
- -- Pressing <PageUp> should scroll the menu upward
- feed('<C-U>sign <Tab><PageUp>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign ^ |
- ]])
- feed('<PageUp>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{s: unplace }{1: }|
- :sign unplace^ |
- ]])
- feed('<PageUp>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{s: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign jump^ |
- ]])
- feed('<PageUp>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{s: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign define^ |
- ]])
- -- pressing <C-E> to end completion should work in middle of the line too
- feed('<Esc>:set wildchazz<Left><Left><Tab>')
- screen:expect([[
- |
- {1:~ }|*6
- {1:~ }{s: wildchar }{1: }|
- {1:~ }{n: wildcharm }{1: }|
- :set wildchar^zz |
- ]])
- feed('<C-E>')
- screen:expect([[
- |
- {1:~ }|*8
- :set wildcha^zz |
- ]])
- -- pressing <C-Y> should select the current match and end completion
- feed('<Esc>:set wildchazz<Left><Left><Tab><C-Y>')
- screen:expect([[
- |
- {1:~ }|*8
- :set wildchar^zz |
- ]])
- feed('<Esc>')
- -- check positioning with multibyte char in pattern
- command('e långfile1')
- command('sp långfile2')
- feed(':b lå<tab>')
- screen:expect([[
- |
- {1:~ }|*3
- {4:långfile2 }|
- |
- {1:~ }|
- {1:~ }{s: långfile1 }{1: }|
- {3:lå}{n: långfile2 }{3: }|
- :b långfile1^ |
- ]])
- -- check doesn't crash on screen resize
- screen:try_resize(20, 6)
- screen:expect([[
- |
- {1:~ }|
- {4:långfile2 }|
- {s: långfile1 } |
- {3:lå}{n: långfile2 }{3: }|
- :b långfile1^ |
- ]])
- screen:try_resize(50, 15)
- screen:expect([[
- |
- {1:~ }|
- {4:långfile2 }|
- |
- {1:~ }|*8
- {1:~ }{s: långfile1 }{1: }|
- {3:lå}{n: långfile2 }{3: }|
- :b långfile1^ |
- ]])
- -- position is calculated correctly with "longest"
- feed('<esc>')
- command('set wildmode=longest:full,full')
- feed(':b lå<tab>')
- screen:expect([[
- |
- {1:~ }|
- {4:långfile2 }|
- |
- {1:~ }|*8
- {1:~ }{n: långfile1 }{1: }|
- {3:lå}{n: långfile2 }{3: }|
- :b långfile^ |
- ]])
- feed('<esc>')
- command('close')
- command('set wildmode=full')
- -- special case: when patterns ends with "/", show menu items aligned
- -- after the "/"
- feed(':e compdir/<tab>')
- screen:expect([[
- |
- {1:~ }|*11
- {1:~ }{s: file1 }{1: }|
- {1:~ }{n: file2 }{1: }|
- :e compdir/file1^ |
- ]])
- end)
- it('wildoptions=pum with scrolled messages', function()
- screen:try_resize(40, 10)
- command('set wildmenu')
- command('set wildoptions=pum')
- feed(':echoerr "fail"|echoerr "error"<cr>')
- screen:expect {
- grid = [[
- |
- {1:~ }|*5
- {4: }|
- {6:fail} |
- {6:error} |
- {5:Press ENTER or type command to continue}^ |
- ]],
- }
- feed(':sign <tab>')
- screen:expect {
- grid = [[
- |
- {1:~ }|*2
- {1:~ }{s: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {4: }{n: place }{4: }|
- {6:fail} {n: undefine } |
- {6:error}{n: unplace } |
- :sign define^ |
- ]],
- }
- feed('d')
- screen:expect {
- grid = [[
- |
- {1:~ }|*5
- {4: }|
- {6:fail} |
- {6:error} |
- :sign defined^ |
- ]],
- }
- end)
- it('wildoptions=pum and wildmode=longest,full #11622', function()
- screen:try_resize(30, 8)
- command('set wildmenu')
- command('set wildoptions=pum')
- command('set wildmode=longest,full')
- -- With 'wildmode' set to 'longest,full', completing a match should display
- -- the longest match, the wildmenu should not be displayed.
- feed(':sign u<Tab>')
- screen:expect {
- grid = [[
- |
- {1:~ }|*6
- :sign un^ |
- ]],
- }
- eq(0, fn.wildmenumode())
- -- pressing <Tab> should display the wildmenu
- feed('<Tab>')
- screen:expect {
- grid = [[
- |
- {1:~ }|*4
- {1:~ }{s: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign undefine^ |
- ]],
- }
- eq(1, fn.wildmenumode())
- -- pressing <Tab> second time should select the next entry in the menu
- feed('<Tab>')
- screen:expect {
- grid = [[
- |
- {1:~ }|*4
- {1:~ }{n: undefine }{1: }|
- {1:~ }{s: unplace }{1: }|
- :sign unplace^ |
- ]],
- }
- end)
- it('wildoptions=pum with a wrapped line in buffer vim-patch:8.2.4655', function()
- screen:try_resize(32, 10)
- api.nvim_buf_set_lines(0, 0, -1, true, { ('a'):rep(100) })
- command('set wildoptions+=pum')
- feed('$')
- feed(':sign <Tab>')
- screen:expect([[
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*3
- aaaa {s: define } |
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign define^ |
- ]])
- end)
- -- oldtest: Test_wildmenu_pum_odd_wildchar()
- it('wildoptions=pum with odd wildchar', function()
- screen:try_resize(30, 10)
- -- Test odd wildchar interactions with pum. Make sure they behave properly
- -- and don't lead to memory corruption due to improperly cleaned up memory.
- exec([[
- set wildoptions=pum
- set wildchar=<C-E>
- ]])
- feed(':sign <C-E>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{s: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign define^ |
- ]])
- -- <C-E> being a wildchar takes priority over its original functionality
- feed('<C-E>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{n: define }{1: }|
- {1:~ }{s: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign jump^ |
- ]])
- feed('<Esc>')
- screen:expect([[
- ^ |
- {1:~ }|*8
- |
- ]])
- -- Escape key can be wildchar too. Double-<Esc> is hard-coded to escape
- -- command-line, and we need to make sure to clean up properly.
- command('set wildchar=<Esc>')
- feed(':sign <Esc>')
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{s: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign define^ |
- ]])
- feed('<Esc>')
- screen:expect([[
- ^ |
- {1:~ }|*8
- |
- ]])
- -- <C-\> can also be wildchar. <C-\><C-N> however will still escape cmdline
- -- and we again need to make sure we clean up properly.
- command([[set wildchar=<C-\>]])
- feed([[:sign <C-\><C-\>]])
- screen:expect([[
- |
- {1:~ }|*2
- {1:~ }{s: define }{1: }|
- {1:~ }{n: jump }{1: }|
- {1:~ }{n: list }{1: }|
- {1:~ }{n: place }{1: }|
- {1:~ }{n: undefine }{1: }|
- {1:~ }{n: unplace }{1: }|
- :sign define^ |
- ]])
- feed('<C-N>')
- screen:expect([[
- ^ |
- {1:~ }|*8
- |
- ]])
- end)
- -- oldtest: Test_wildmenu_pum_hl_match()
- it('highlighting matched text in cmdline pum', function()
- exec([[
- set wildoptions=pum,fuzzy
- hi PmenuMatchSel guifg=Blue guibg=Grey
- hi PmenuMatch guifg=Blue guibg=Plum1
- ]])
- feed(':sign plc<Tab>')
- screen:expect([[
- |
- {1:~ }|*16
- {1:~ }{s: }{ms:pl}{s:a}{ms:c}{s:e }{1: }|
- {1:~ }{n: un}{mn:pl}{n:a}{mn:c}{n:e }{1: }|
- :sign place^ |
- ]])
- feed('<Tab>')
- screen:expect([[
- |
- {1:~ }|*16
- {1:~ }{n: }{mn:pl}{n:a}{mn:c}{n:e }{1: }|
- {1:~ }{s: un}{ms:pl}{s:a}{ms:c}{s:e }{1: }|
- :sign unplace^ |
- ]])
- feed('<Tab>')
- screen:expect([[
- |
- {1:~ }|*16
- {1:~ }{n: }{mn:pl}{n:a}{mn:c}{n:e }{1: }|
- {1:~ }{n: un}{mn:pl}{n:a}{mn:c}{n:e }{1: }|
- :sign plc^ |
- ]])
- feed('<Esc>')
- command('set wildoptions-=fuzzy')
- feed(':sign un<Tab>')
- screen:expect([[
- |
- {1:~ }|*16
- {1:~ }{s: }{ms:un}{s:define }{1: }|
- {1:~ }{n: }{mn:un}{n:place }{1: }|
- :sign undefine^ |
- ]])
- feed('<Tab>')
- screen:expect([[
- |
- {1:~ }|*16
- {1:~ }{n: }{mn:un}{n:define }{1: }|
- {1:~ }{s: }{ms:un}{s:place }{1: }|
- :sign unplace^ |
- ]])
- feed('<Tab>')
- screen:expect([[
- |
- {1:~ }|*16
- {1:~ }{n: }{mn:un}{n:define }{1: }|
- {1:~ }{n: }{mn:un}{n:place }{1: }|
- :sign un^ |
- ]])
- end)
- it(
- 'cascading highlights for matched text (PmenuMatch, PmenuMatchSel) in cmdline pum',
- function()
- screen:add_extra_attr_ids {
- [100] = {
- background = Screen.colors.Grey,
- italic = true,
- underline = true,
- foreground = Screen.colors.White,
- },
- [101] = {
- strikethrough = true,
- foreground = Screen.colors.Grey0,
- italic = true,
- bold = true,
- underline = true,
- background = Screen.colors.White,
- },
- [102] = {
- strikethrough = true,
- foreground = Screen.colors.Red,
- italic = true,
- underline = true,
- background = Screen.colors.Grey,
- },
- [103] = {
- foreground = Screen.colors.Yellow,
- italic = true,
- bold = true,
- underline = true,
- background = Screen.colors.Pink,
- },
- }
- exec([[
- set wildoptions=pum,fuzzy
- hi Pmenu guifg=White guibg=Grey gui=underline,italic
- hi PmenuSel guifg=Red gui=strikethrough
- hi PmenuMatch guifg=Yellow guibg=Pink gui=bold
- hi PmenuMatchSel guifg=Black guibg=White
- ]])
- feed(':sign plc<Tab>')
- screen:expect([[
- |
- {1:~ }|*16
- {1:~ }{102: }{101:pl}{102:a}{101:c}{102:e }{1: }|
- {1:~ }{100: un}{103:pl}{100:a}{103:c}{100:e }{1: }|
- :sign place^ |
- ]])
- end
- )
- end
- it("'pumheight'", function()
- screen:try_resize(32, 8)
- feed('isome long prefix before the ')
- command('set completeopt+=noinsert,noselect')
- command('set linebreak')
- command('set pumheight=2')
- fn.complete(29, { 'word', 'choice', 'text', 'thing' })
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:--------------------------------]|*7
- [3:--------------------------------]|
- ## grid 2
- some long prefix before the ^ |
- {1:~ }|*6
- ## grid 3
- {2:-- INSERT --} |
- ## grid 4
- {n: word }{c: }|
- {n: choice}{s: }|
- ]],
- float_pos = {
- [4] = { -1, 'NW', 2, 1, 24, false, 100 },
- },
- }
- else
- screen:expect([[
- some long prefix before the ^ |
- {1:~ }{n: word }{c: }|
- {1:~ }{n: choice}{s: }|
- {1:~ }|*4
- {2:-- INSERT --} |
- ]])
- end
- end)
- it("'pumwidth'", function()
- screen:try_resize(32, 8)
- feed('isome long prefix before the ')
- command('set completeopt+=noinsert,noselect')
- command('set linebreak')
- command('set pumwidth=8')
- fn.complete(29, { 'word', 'choice', 'text', 'thing' })
- if multigrid then
- screen:expect {
- grid = [[
- ## grid 1
- [2:--------------------------------]|*7
- [3:--------------------------------]|
- ## grid 2
- some long prefix before the ^ |
- {1:~ }|*6
- ## grid 3
- {2:-- INSERT --} |
- ## grid 4
- {n: word }|
- {n: choice}|
- {n: text }|
- {n: thing }|
- ]],
- float_pos = {
- [4] = { -1, 'NW', 2, 1, 25, false, 100 },
- },
- }
- else
- screen:expect([[
- some long prefix before the ^ |
- {1:~ }{n: word }|
- {1:~ }{n: choice}|
- {1:~ }{n: text }|
- {1:~ }{n: thing }|
- {1:~ }|*2
- {2:-- INSERT --} |
- ]])
- end
- end)
- it('does not crash when displayed in the last column with rightleft #12032', function()
- local col = 30
- local items = { 'word', 'choice', 'text', 'thing' }
- local max_len = 0
- for _, v in ipairs(items) do
- max_len = max_len < #v and #v or max_len
- end
- screen:try_resize(col, 8)
- command('set rightleft')
- command('call setline(1, repeat(" ", &columns - ' .. max_len .. '))')
- feed('$i')
- fn.complete(col - max_len, items)
- feed('<c-y>')
- assert_alive()
- end)
- it('truncates double-width character correctly without scrollbar', function()
- screen:try_resize(32, 8)
- command('set completeopt+=menuone,noselect')
- feed('i' .. string.rep(' ', 13))
- fn.complete(14, { '哦哦哦哦哦哦哦哦哦哦' })
- if multigrid then
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*7
- [3:--------------------------------]|
- ## grid 2
- ^ |
- {1:~ }|*6
- ## grid 3
- {2:-- INSERT --} |
- ## grid 4
- {n: 哦哦哦哦哦哦哦哦哦>}|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 12, false, 100 } },
- })
- else
- screen:expect([[
- ^ |
- {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}|
- {1:~ }|*5
- {2:-- INSERT --} |
- ]])
- end
- end)
- it('truncates double-width character correctly with scrollbar', function()
- screen:try_resize(32, 8)
- command('set completeopt+=noselect')
- command('set pumheight=4')
- feed('i' .. string.rep(' ', 12))
- local items = {}
- for _ = 1, 8 do
- table.insert(items, { word = '哦哦哦哦哦哦哦哦哦哦', equal = 1, dup = 1 })
- end
- fn.complete(13, items)
- if multigrid then
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*7
- [3:--------------------------------]|
- ## grid 2
- ^ |
- {1:~ }|*6
- ## grid 3
- {2:-- INSERT --} |
- ## grid 4
- {n: 哦哦哦哦哦哦哦哦哦>}{c: }|*2
- {n: 哦哦哦哦哦哦哦哦哦>}{s: }|*2
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 11, false, 100 } },
- })
- else
- screen:expect([[
- ^ |
- {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{c: }|*2
- {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{s: }|*2
- {1:~ }|*2
- {2:-- INSERT --} |
- ]])
- end
- end)
- it('supports mousemodel=popup', function()
- screen:try_resize(32, 6)
- exec([[
- call setline(1, 'popup menu test')
- set mouse=a mousemodel=popup
- " Delete the default MenuPopup event handler.
- autocmd! nvim.popupmenu
- aunmenu PopUp
- menu PopUp.foo :let g:menustr = 'foo'<CR>
- menu PopUp.bar :let g:menustr = 'bar'<CR>
- menu PopUp.baz :let g:menustr = 'baz'<CR>
- ]])
- if multigrid then
- api.nvim_input_mouse('right', 'press', '', 2, 0, 4)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- |
- ## grid 4
- {n: foo }|
- {n: bar }|
- {n: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
- })
- else
- feed('<RightMouse><4,0>')
- screen:expect([[
- ^popup menu test |
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: baz }{1: }|
- {1:~ }|
- |
- ]])
- end
- feed('<Down>')
- if multigrid then
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- |
- ## grid 4
- {s: foo }|
- {n: bar }|
- {n: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
- })
- else
- screen:expect([[
- ^popup menu test |
- {1:~ }{s: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: baz }{1: }|
- {1:~ }|
- |
- ]])
- end
- feed('<Down>')
- if multigrid then
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- |
- ## grid 4
- {n: foo }|
- {s: bar }|
- {n: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
- })
- else
- screen:expect([[
- ^popup menu test |
- {1:~ }{n: foo }{1: }|
- {1:~ }{s: bar }{1: }|
- {1:~ }{n: baz }{1: }|
- {1:~ }|
- |
- ]])
- end
- feed('<CR>')
- if multigrid then
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'bar' |
- ]],
- })
- else
- screen:expect([[
- ^popup menu test |
- {1:~ }|*4
- :let g:menustr = 'bar' |
- ]])
- end
- eq('bar', api.nvim_get_var('menustr'))
- if multigrid then
- api.nvim_input_mouse('right', 'press', '', 2, 2, 20)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'bar' |
- ## grid 4
- {n: foo }|
- {n: bar }|
- {n: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 3, 19, false, 250 } },
- })
- else
- feed('<RightMouse><20,2>')
- screen:expect([[
- ^popup menu test |
- {1:~ }|*2
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- :let g:menustr = 'b{n: baz } |
- ]])
- end
- if multigrid then
- api.nvim_input_mouse('right', 'press', '', 2, 0, 18)
- screen:expect {
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'bar' |
- ## grid 4
- {n: foo }|
- {n: bar }|
- {n: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 17, false, 250 } },
- }
- else
- feed('<RightMouse><18,0>')
- screen:expect([[
- ^popup menu test |
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: baz }{1: }|
- {1:~ }|
- :let g:menustr = 'bar' |
- ]])
- end
- if multigrid then
- api.nvim_input_mouse('right', 'press', '', 4, 1, 3)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'bar' |
- ## grid 4
- {n: foo }|
- {n: bar }|
- {n: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 3, 19, false, 250 } },
- })
- else
- feed('<RightMouse><20,2>')
- screen:expect([[
- ^popup menu test |
- {1:~ }|*2
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- :let g:menustr = 'b{n: baz } |
- ]])
- end
- if multigrid then
- api.nvim_input_mouse('left', 'press', '', 4, 2, 2)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'baz' |
- ]],
- })
- else
- feed('<LeftMouse><21,5>')
- screen:expect([[
- ^popup menu test |
- {1:~ }|*4
- :let g:menustr = 'baz' |
- ]])
- end
- eq('baz', api.nvim_get_var('menustr'))
- if multigrid then
- api.nvim_input_mouse('right', 'press', '', 2, 0, 4)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'baz' |
- ## grid 4
- {n: foo }|
- {n: bar }|
- {n: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
- })
- else
- feed('<RightMouse><4,0>')
- screen:expect([[
- ^popup menu test |
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: baz }{1: }|
- {1:~ }|
- :let g:menustr = 'baz' |
- ]])
- end
- if multigrid then
- api.nvim_input_mouse('right', 'drag', '', 2, 3, 6)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'baz' |
- ## grid 4
- {n: foo }|
- {n: bar }|
- {s: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
- })
- else
- feed('<RightDrag><6,3>')
- screen:expect([[
- ^popup menu test |
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{s: baz }{1: }|
- {1:~ }|
- :let g:menustr = 'baz' |
- ]])
- end
- if multigrid then
- api.nvim_input_mouse('right', 'release', '', 2, 1, 6)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'foo' |
- ]],
- })
- else
- feed('<RightRelease><6,1>')
- screen:expect([[
- ^popup menu test |
- {1:~ }|*4
- :let g:menustr = 'foo' |
- ]])
- end
- eq('foo', api.nvim_get_var('menustr'))
- eq(false, screen.options.mousemoveevent)
- if multigrid then
- api.nvim_input_mouse('right', 'press', '', 2, 0, 4)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'foo' |
- ## grid 4
- {n: foo }|
- {n: bar }|
- {n: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
- })
- else
- feed('<RightMouse><4,0>')
- screen:expect([[
- ^popup menu test |
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: baz }{1: }|
- {1:~ }|
- :let g:menustr = 'foo' |
- ]])
- end
- eq(true, screen.options.mousemoveevent)
- if multigrid then
- api.nvim_input_mouse('wheel', 'up', '', 2, 0, 4)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'foo' |
- ## grid 4
- {s: foo }|
- {n: bar }|
- {n: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
- })
- else
- feed('<ScrollWheelUp><4,0>')
- screen:expect([[
- ^popup menu test |
- {1:~ }{s: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: baz }{1: }|
- {1:~ }|
- :let g:menustr = 'foo' |
- ]])
- end
- eq(true, screen.options.mousemoveevent)
- if multigrid then
- api.nvim_input_mouse('move', '', '', 4, 2, 3)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'foo' |
- ## grid 4
- {n: foo }|
- {n: bar }|
- {s: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
- })
- else
- feed('<MouseMove><6,3>')
- screen:expect([[
- ^popup menu test |
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{s: baz }{1: }|
- {1:~ }|
- :let g:menustr = 'foo' |
- ]])
- end
- eq(true, screen.options.mousemoveevent)
- if multigrid then
- api.nvim_input_mouse('wheel', 'down', '', 4, 2, 3)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'foo' |
- ## grid 4
- {n: foo }|
- {s: bar }|
- {n: baz }|
- ]],
- float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } },
- })
- else
- feed('<ScrollWheelDown><6,3>')
- screen:expect([[
- ^popup menu test |
- {1:~ }{n: foo }{1: }|
- {1:~ }{s: bar }{1: }|
- {1:~ }{n: baz }{1: }|
- {1:~ }|
- :let g:menustr = 'foo' |
- ]])
- end
- eq(true, screen.options.mousemoveevent)
- if multigrid then
- api.nvim_input_mouse('left', 'press', '', 4, 1, 3)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*5
- [3:--------------------------------]|
- ## grid 2
- ^popup menu test |
- {1:~ }|*4
- ## grid 3
- :let g:menustr = 'bar' |
- ]],
- })
- else
- feed('<LeftMouse><6,2>')
- screen:expect([[
- ^popup menu test |
- {1:~ }|*4
- :let g:menustr = 'bar' |
- ]])
- end
- eq(false, screen.options.mousemoveevent)
- eq('bar', api.nvim_get_var('menustr'))
- command('set laststatus=0 | botright split')
- if multigrid then
- api.nvim_input_mouse('right', 'press', '', 5, 1, 20)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*2
- {3:[No Name] [+] }|
- [5:--------------------------------]|*2
- [3:--------------------------------]|
- ## grid 2
- popup menu test |
- {1:~ }|
- ## grid 3
- :let g:menustr = 'bar' |
- ## grid 4
- {n: foo }|
- {n: bar }|
- {n: baz }|
- ## grid 5
- ^popup menu test |
- {1:~ }|
- ]],
- float_pos = { [4] = { -1, 'SW', 5, 1, 19, false, 250 } },
- })
- else
- feed('<RightMouse><20,4>')
- screen:expect([[
- popup menu test |
- {1:~ }{n: foo }{1: }|
- {3:[No Name] [+] }{n: bar }{3: }|
- ^popup menu test {n: baz } |
- {1:~ }|
- :let g:menustr = 'bar' |
- ]])
- end
- if multigrid then
- api.nvim_input_mouse('left', 'press', '', 4, 2, 2)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*2
- {3:[No Name] [+] }|
- [5:--------------------------------]|*2
- [3:--------------------------------]|
- ## grid 2
- popup menu test |
- {1:~ }|
- ## grid 3
- :let g:menustr = 'baz' |
- ## grid 5
- ^popup menu test |
- {1:~ }|
- ]],
- })
- else
- feed('<LeftMouse><21,3>')
- screen:expect([[
- popup menu test |
- {1:~ }|
- {3:[No Name] [+] }|
- ^popup menu test |
- {1:~ }|
- :let g:menustr = 'baz' |
- ]])
- end
- eq('baz', api.nvim_get_var('menustr'))
- command('set winwidth=1 | rightbelow vsplit')
- if multigrid then
- api.nvim_input_mouse('right', 'press', '', 6, 1, 14)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*2
- {3:[No Name] [+] }|
- [5:---------------]│[6:----------------]|*2
- [3:--------------------------------]|
- ## grid 2
- popup menu test |
- {1:~ }|
- ## grid 3
- :let g:menustr = 'baz' |
- ## grid 4
- {n: foo}|
- {n: bar}|
- {n: baz}|
- ## grid 5
- popup menu test|
- {1:~ }|
- ## grid 6
- ^popup menu test |
- {1:~ }|
- ]],
- float_pos = { [4] = { -1, 'SW', 6, 1, 12, false, 250 } },
- })
- else
- feed('<RightMouse><30,4>')
- screen:expect([[
- popup menu test |
- {1:~ }{n: foo}|
- {3:[No Name] [+] }{n: bar}|
- popup menu test│^popup menu t{n: baz}|
- {1:~ }│{1:~ }|
- :let g:menustr = 'baz' |
- ]])
- end
- if multigrid then
- api.nvim_input_mouse('left', 'press', '', 4, 0, 2)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*2
- {3:[No Name] [+] }|
- [5:---------------]│[6:----------------]|*2
- [3:--------------------------------]|
- ## grid 2
- popup menu test |
- {1:~ }|
- ## grid 3
- :let g:menustr = 'foo' |
- ## grid 5
- popup menu test|
- {1:~ }|
- ## grid 6
- ^popup menu test |
- {1:~ }|
- ]],
- })
- else
- feed('<LeftMouse><31,1>')
- screen:expect([[
- popup menu test |
- {1:~ }|
- {3:[No Name] [+] }|
- popup menu test│^popup menu test |
- {1:~ }│{1:~ }|
- :let g:menustr = 'foo' |
- ]])
- end
- eq('foo', api.nvim_get_var('menustr'))
- command('setlocal winbar=WINBAR')
- if multigrid then
- api.nvim_input_mouse('right', 'press', '', 6, 1, 14)
- screen:expect({
- grid = [[
- ## grid 1
- [2:--------------------------------]|*2
- {3:[No Name] [+] }|
- [5:---------------]│[6:----------------]|*2
- [3:--------------------------------]|
- ## grid 2
- popup menu test |
- {1:~ }|
- ## grid 3
- :let g:menustr = 'foo' |
- ## grid 4
- {n: foo}|
- {n: bar}|
- {n: baz}|
- ## grid 5
- popup menu test|
- {1:~ }|
- ## grid 6
- {2:WINBAR }|
- ^popup menu test |
- ]],
- float_pos = { [4] = { -1, 'SW', 6, 1, 12, false, 250 } },
- })
- else
- feed('<RightMouse><30,4>')
- screen:expect([[
- popup menu test |
- {1:~ }{n: foo}|
- {3:[No Name] [+] }{n: bar}|
- popup menu test│{2:WINBAR }{n: baz}|
- {1:~ }│^popup menu test |
- :let g:menustr = 'foo' |
- ]])
- end
- local no_menu_screen ---@type string|test.function.ui.screen.Expect
- if multigrid then
- api.nvim_input_mouse('left', 'press', '', 4, 1, 2)
- no_menu_screen = {
- grid = [[
- ## grid 1
- [2:--------------------------------]|*2
- {3:[No Name] [+] }|
- [5:---------------]│[6:----------------]|*2
- [3:--------------------------------]|
- ## grid 2
- popup menu test |
- {1:~ }|
- ## grid 3
- :let g:menustr = 'bar' |
- ## grid 5
- popup menu test|
- {1:~ }|
- ## grid 6
- {2:WINBAR }|
- ^popup menu test |
- ]],
- }
- else
- feed('<LeftMouse><31,2>')
- no_menu_screen = {
- grid = [[
- popup menu test |
- {1:~ }|
- {3:[No Name] [+] }|
- popup menu test│{2:WINBAR }|
- {1:~ }│^popup menu test |
- :let g:menustr = 'bar' |
- ]],
- }
- end
- screen:expect(no_menu_screen)
- eq('bar', api.nvim_get_var('menustr'))
- local no_sel_screen ---@type string|test.function.ui.screen.Expect
- if multigrid then
- no_sel_screen = {
- grid = [[
- ## grid 1
- [2:--------------------------------]|*2
- {3:[No Name] [+] }|
- [5:---------------]│[6:----------------]|*2
- [3:--------------------------------]|
- ## grid 2
- popup menu test |
- {1:~ }|
- ## grid 3
- :let g:menustr = 'bar' |
- ## grid 4
- {n: foo }|
- {n: bar }|
- {n: baz }|
- ## grid 5
- popup menu test|
- {1:~ }|
- ## grid 6
- {2:WINBAR }|
- ^popup menu test |
- ]],
- float_pos = { [4] = { -1, 'NW', 1, 1, 19, false, 250 } },
- }
- else
- no_sel_screen = {
- grid = [[
- popup menu test |
- {1:~ }{n: foo }{1: }|
- {3:[No Name] [+] }{n: bar }{3: }|
- popup menu test│{2:WIN}{n: baz }{2: }|
- {1:~ }│^popup menu test |
- :let g:menustr = 'bar' |
- ]],
- }
- end
- local sel_screens = {} ---@type (string|test.function.ui.screen.Expect)[]
- for i, s in ipairs({ 'foo', 'bar', 'baz' }) do
- local sel_screen = vim.deepcopy(no_sel_screen)
- local grid = assert(sel_screen.grid)
- grid = grid:gsub(vim.pesc(('{n: %s }'):format(s)), ('{s: %s }'):format(s))
- sel_screen.grid = grid
- sel_screens[i] = sel_screen
- end
- command([[let g:menustr = '']])
- local g = multigrid and 1 or 0
- api.nvim_input_mouse('right', 'press', '', g, 0, 20)
- screen:expect(no_sel_screen)
- api.nvim_input_mouse('move', '', '', g, 1, 19)
- screen:expect(sel_screens[1])
- api.nvim_input_mouse('move', '', '', g, 1, 18)
- screen:expect(no_sel_screen)
- api.nvim_input_mouse('move', '', '', g, 2, 23)
- screen:expect(sel_screens[2])
- api.nvim_input_mouse('move', '', '', g, 2, 24)
- screen:expect(no_sel_screen)
- api.nvim_input_mouse('move', '', '', g, 3, 19)
- screen:expect(sel_screens[3])
- api.nvim_input_mouse('left', 'press', '', g, 3, 18)
- screen:expect(no_menu_screen)
- eq('', api.nvim_get_var('menustr'))
- command('wincmd t | set rightleft')
- if multigrid then
- no_menu_screen = {
- grid = [[
- ## grid 1
- [2:--------------------------------]|*2
- {4:[No Name] [+] }|
- [5:---------------]│[6:----------------]|*2
- [3:--------------------------------]|
- ## grid 2
- tset unem pupo^p|
- {1: ~}|
- ## grid 3
- :let g:menustr = 'bar' |
- ## grid 5
- popup menu test|
- {1:~ }|
- ## grid 6
- {2:WINBAR }|
- popup menu test |
- ]],
- }
- else
- no_menu_screen = {
- grid = [[
- tset unem pupo^p|
- {1: ~}|
- {4:[No Name] [+] }|
- popup menu test│{2:WINBAR }|
- {1:~ }│popup menu test |
- :let g:menustr = 'bar' |
- ]],
- }
- end
- screen:expect(no_menu_screen)
- if multigrid then
- no_sel_screen = {
- grid = [[
- ## grid 1
- [2:--------------------------------]|*2
- {4:[No Name] [+] }|
- [5:---------------]│[6:----------------]|*2
- [3:--------------------------------]|
- ## grid 2
- tset unem pupo^p|
- {1: ~}|
- ## grid 3
- :let g:menustr = 'bar' |
- ## grid 4
- {n: oof }|
- {n: rab }|
- {n: zab }|
- ## grid 5
- popup menu test|
- {1:~ }|
- ## grid 6
- {2:WINBAR }|
- popup menu test |
- ]],
- float_pos = { [4] = { -1, 'NW', 1, 1, 17, false, 250 } },
- }
- else
- no_sel_screen = {
- grid = [[
- tset unem pupo^p|
- {1: }{n: oof }{1: ~}|
- {4:[No Name] [+] }{n: rab }{4: }|
- popup menu test│{2:W}{n: zab }{2: }|
- {1:~ }│popup menu test |
- :let g:menustr = 'bar' |
- ]],
- }
- end
- for i, s in ipairs({ 'oof', 'rab', 'zab' }) do
- local sel_screen = vim.deepcopy(no_sel_screen)
- local grid = assert(sel_screen.grid)
- grid = grid:gsub(vim.pesc(('{n: %s }'):format(s)), ('{s: %s }'):format(s))
- sel_screen.grid = grid
- sel_screens[i] = sel_screen
- end
- api.nvim_input_mouse('right', 'press', '', g, 0, 20)
- screen:expect(no_sel_screen)
- api.nvim_input_mouse('move', '', '', g, 1, 21)
- screen:expect(sel_screens[1])
- api.nvim_input_mouse('move', '', '', g, 1, 22)
- screen:expect(no_sel_screen)
- api.nvim_input_mouse('move', '', '', g, 2, 17)
- screen:expect(sel_screens[2])
- api.nvim_input_mouse('move', '', '', g, 2, 16)
- screen:expect(no_sel_screen)
- api.nvim_input_mouse('move', '', '', g, 3, 21)
- screen:expect(sel_screens[3])
- api.nvim_input_mouse('left', 'press', '', g, 3, 22)
- screen:expect(no_menu_screen)
- eq('', api.nvim_get_var('menustr'))
- command('set norightleft')
- end)
- if not multigrid then
- -- oldtest: Test_popup_command_dump()
- it(':popup command', function()
- exec([[
- " Delete the default MenuPopup event handler.
- autocmd! nvim.popupmenu
- func ChangeMenu()
- aunmenu PopUp.&Paste
- nnoremenu 1.40 PopUp.&Paste :echomsg "pasted"<CR>
- echomsg 'changed'
- return "\<Ignore>"
- endfunc
- let lines =<< trim END
- one two three four five
- and one two Xthree four five
- one more two three four five
- END
- call setline(1, lines)
- aunmenu *
- source $VIMRUNTIME/menu.vim
- ]])
- feed('/X<CR>:popup PopUp<CR>')
- screen:expect([[
- one two three four five |
- and one two {7:^X}three four five |
- one more tw{n: Undo } |
- {1:~ }{n: }{1: }|
- {1:~ }{n: Paste }{1: }|
- {1:~ }{n: }{1: }|
- {1:~ }{n: Select Word }{1: }|
- {1:~ }{n: Select Sentence }{1: }|
- {1:~ }{n: Select Paragraph }{1: }|
- {1:~ }{n: Select Line }{1: }|
- {1:~ }{n: Select Block }{1: }|
- {1:~ }{n: Select All }{1: }|
- {1:~ }|*7
- :popup PopUp |
- ]])
- -- go to the Paste entry in the menu
- feed('jj')
- screen:expect([[
- one two three four five |
- and one two {7:^X}three four five |
- one more tw{n: Undo } |
- {1:~ }{n: }{1: }|
- {1:~ }{s: Paste }{1: }|
- {1:~ }{n: }{1: }|
- {1:~ }{n: Select Word }{1: }|
- {1:~ }{n: Select Sentence }{1: }|
- {1:~ }{n: Select Paragraph }{1: }|
- {1:~ }{n: Select Line }{1: }|
- {1:~ }{n: Select Block }{1: }|
- {1:~ }{n: Select All }{1: }|
- {1:~ }|*7
- :popup PopUp |
- ]])
- -- Select a word
- feed('j')
- screen:expect([[
- one two three four five |
- and one two {7:^X}three four five |
- one more tw{n: Undo } |
- {1:~ }{n: }{1: }|
- {1:~ }{n: Paste }{1: }|
- {1:~ }{n: }{1: }|
- {1:~ }{s: Select Word }{1: }|
- {1:~ }{n: Select Sentence }{1: }|
- {1:~ }{n: Select Paragraph }{1: }|
- {1:~ }{n: Select Line }{1: }|
- {1:~ }{n: Select Block }{1: }|
- {1:~ }{n: Select All }{1: }|
- {1:~ }|*7
- :popup PopUp |
- ]])
- feed('<Esc>')
- command('set rightleft')
- feed('/X<CR>:popup PopUp<CR>')
- screen:expect([[
- evif ruof eerht owt eno|
- evif ruof eerht{7:^X} owt eno dna|
- {n: odnU }wt erom eno|
- {1: }{n: }{1: ~}|
- {1: }{n: etsaP }{1: ~}|
- {1: }{n: }{1: ~}|
- {1: }{n: droW tceleS }{1: ~}|
- {1: }{n: ecnetneS tceleS }{1: ~}|
- {1: }{n: hpargaraP tceleS }{1: ~}|
- {1: }{n: eniL tceleS }{1: ~}|
- {1: }{n: kcolB tceleS }{1: ~}|
- {1: }{n: llA tceleS }{1: ~}|
- {1: ~}|*7
- :popup PopUp |
- ]])
- feed('<Esc>')
- command('set norightleft')
- -- Set an <expr> mapping to change a menu entry while it's displayed.
- -- The text should not change but the command does.
- -- Also verify that "changed" shows up, which means the mapping triggered.
- command('nnoremap <expr> <F2> ChangeMenu()')
- feed('/X<CR>:popup PopUp<CR><F2>')
- screen:expect([[
- one two three four five |
- and one two {7:^X}three four five |
- one more tw{n: Undo } |
- {1:~ }{n: }{1: }|
- {1:~ }{n: Paste }{1: }|
- {1:~ }{n: }{1: }|
- {1:~ }{n: Select Word }{1: }|
- {1:~ }{n: Select Sentence }{1: }|
- {1:~ }{n: Select Paragraph }{1: }|
- {1:~ }{n: Select Line }{1: }|
- {1:~ }{n: Select Block }{1: }|
- {1:~ }{n: Select All }{1: }|
- {1:~ }|*7
- changed |
- ]])
- -- Select the Paste entry, executes the changed menu item.
- feed('jj<CR>')
- screen:expect([[
- one two three four five |
- and one two {7:^X}three four five |
- one more two three four five |
- {1:~ }|*16
- pasted |
- ]])
- -- Add a window toolbar to the window and check the :popup menu position.
- command('setlocal winbar=TEST')
- feed('/X<CR>:popup PopUp<CR>')
- screen:expect([[
- {2:TEST }|
- one two three four five |
- and one two {7:^X}three four five |
- one more tw{n: Undo } |
- {1:~ }{n: }{1: }|
- {1:~ }{n: Paste }{1: }|
- {1:~ }{n: }{1: }|
- {1:~ }{n: Select Word }{1: }|
- {1:~ }{n: Select Sentence }{1: }|
- {1:~ }{n: Select Paragraph }{1: }|
- {1:~ }{n: Select Line }{1: }|
- {1:~ }{n: Select Block }{1: }|
- {1:~ }{n: Select All }{1: }|
- {1:~ }|*6
- :popup PopUp |
- ]])
- feed('<Esc>')
- end)
- -- oldtest: Test_mouse_popup_position()
- it('position of right-click menu when clicking near edge', function()
- screen:try_resize(50, 20)
- exec([[
- set mousemodel=popup_setpos
- " Delete the default MenuPopup event handler.
- autocmd! nvim.popupmenu
- aunmenu *
- source $VIMRUNTIME/menu.vim
- call setline(1, join(range(20)))
- ]])
- api.nvim_input_mouse('right', 'press', '', 0, 0, 45 - 1)
- screen:expect([[
- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ^18 19 |
- {1:~ }{n: Undo }|
- {1:~ }{n: }|
- {1:~ }{n: Paste }|
- {1:~ }{n: }|
- {1:~ }{n: Select Word }|
- {1:~ }{n: Select Sentence }|
- {1:~ }{n: Select Paragraph}|
- {1:~ }{n: Select Line }|
- {1:~ }{n: Select Block }|
- {1:~ }{n: Select All }|
- {1:~ }|*8
- |
- ]])
- feed('<Esc>')
- command('set rightleft')
- api.nvim_input_mouse('right', 'press', '', 0, 0, 50 - 45)
- screen:expect([[
- 91 8^1 71 61 51 41 31 21 11 01 9 8 7 6 5 4 3 2 1 0|
- {n: odnU }{1: ~}|
- {n: }{1: ~}|
- {n: etsaP }{1: ~}|
- {n: }{1: ~}|
- {n: droW tceleS }{1: ~}|
- {n: ecnetneS tceleS }{1: ~}|
- {n:hpargaraP tceleS }{1: ~}|
- {n: eniL tceleS }{1: ~}|
- {n: kcolB tceleS }{1: ~}|
- {n: llA tceleS }{1: ~}|
- {1: ~}|*8
- |
- ]])
- feed('<Esc>')
- command('set norightleft')
- end)
- describe('"kind" and "menu"', function()
- before_each(function()
- screen:try_resize(30, 8)
- exec([[
- func CompleteFunc( findstart, base )
- if a:findstart
- return 0
- endif
- return {
- \ 'words': [
- \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', },
- \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', },
- \ { 'word': 'aword3', 'menu': 'extra text 3', 'kind': 'W', },
- \]}
- endfunc
- set completeopt=menu
- set completefunc=CompleteFunc
- ]])
- end)
- -- oldtest: Test_pum_highlights_default()
- it('default highlight groups', function()
- feed('iaw<C-X><C-u>')
- screen:expect([[
- aword1^ |
- {s:aword1 W extra text 1 }{1: }|
- {n:aword2 W extra text 2 }{1: }|
- {n:aword3 W extra text 3 }{1: }|
- {1:~ }|*3
- {2:-- }{5:match 1 of 3} |
- ]])
- end)
- -- oldtest: Test_pum_highlights_custom()
- it('custom highlight groups', function()
- exec([[
- hi PmenuKind guifg=Red guibg=Plum1
- hi PmenuKindSel guifg=Red guibg=Grey
- hi PmenuExtra guifg=White guibg=Plum1
- hi PmenuExtraSel guifg=Black guibg=Grey
- ]])
- feed('iaw<C-X><C-u>')
- screen:expect([[
- aword1^ |
- {s:aword1 }{ks:W }{xs:extra text 1 }{1: }|
- {n:aword2 }{kn:W }{xn:extra text 2 }{1: }|
- {n:aword3 }{kn:W }{xn:extra text 3 }{1: }|
- {1:~ }|*3
- {2:-- }{5:match 1 of 3} |
- ]])
- end)
- end)
- -- oldtest: Test_pum_highlights_match()
- it('can highlight matched text', function()
- exec([[
- func Omni_test(findstart, base)
- if a:findstart
- return col(".")
- endif
- return {
- \ 'words': [
- \ { 'word': 'foo', 'kind': 'fookind' },
- \ { 'word': 'foofoo', 'kind': 'fookind' },
- \ { 'word': 'foobar', 'kind': 'fookind' },
- \ { 'word': 'fooBaz', 'kind': 'fookind' },
- \ { 'word': 'foobala', 'kind': 'fookind' },
- \ { 'word': '你好' },
- \ { 'word': '你好吗' },
- \ { 'word': '你不好吗' },
- \ { 'word': '你可好吗' },
- \]}
- endfunc
- func Comp()
- let col = col('.')
- if getline('.') == 'f'
- let col -= 1
- endif
- call complete(col, [
- \ #{word: "foo", icase: 1},
- \ #{word: "Foobar", icase: 1},
- \ #{word: "fooBaz", icase: 1},
- \])
- return ''
- endfunc
- set omnifunc=Omni_test
- set completeopt=menu,noinsert,fuzzy
- hi PmenuMatchSel guifg=Blue guibg=Grey
- hi PmenuMatch guifg=Blue guibg=Plum1
- ]])
- feed('i<C-X><C-O>')
- local pum_start = [[
- ^ |
- {s:foo fookind }{1: }|
- {n:foofoo fookind }{1: }|
- {n:foobar fookind }{1: }|
- {n:fooBaz fookind }{1: }|
- {n:foobala fookind }{1: }|
- {n:你好 }{1: }|
- {n:你好吗 }{1: }|
- {n:你不好吗 }{1: }|
- {n:你可好吗 }{1: }|
- {1:~ }|*9
- {2:-- }{5:match 1 of 9} |
- ]]
- screen:expect(pum_start)
- feed('fo')
- screen:expect([[
- fo^ |
- {ms:fo}{s:o fookind }{1: }|
- {mn:fo}{n:ofoo fookind }{1: }|
- {mn:fo}{n:obar fookind }{1: }|
- {mn:fo}{n:oBaz fookind }{1: }|
- {mn:fo}{n:obala fookind }{1: }|
- {1:~ }|*13
- {2:-- }{5:match 1 of 9} |
- ]])
- feed('<Esc>S<C-X><C-O>')
- screen:expect(pum_start)
- feed('你')
- screen:expect([[
- 你^ |
- {ms:你}{s:好 }{1: }|
- {mn:你}{n:好吗 }{1: }|
- {mn:你}{n:不好吗 }{1: }|
- {mn:你}{n:可好吗 }{1: }|
- {1:~ }|*14
- {2:-- }{5:match 1 of 9} |
- ]])
- feed('吗')
- screen:expect([[
- 你吗^ |
- {ms:你}{s:好}{ms:吗}{s: }{1: }|
- {mn:你}{n:不好}{mn:吗}{n: }{1: }|
- {mn:你}{n:可好}{mn:吗}{n: }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 1 of 9} |
- ]])
- feed('<C-E><Esc>')
- command('set rightleft')
- feed('S<C-X><C-O>')
- local pum_start_rl = [[
- ^ |
- {1: }{s: dnikoof oof}|
- {1: }{n: dnikoof oofoof}|
- {1: }{n: dnikoof raboof}|
- {1: }{n: dnikoof zaBoof}|
- {1: }{n: dnikoof alaboof}|
- {1: }{n: 好你}|
- {1: }{n: 吗好你}|
- {1: }{n: 吗好不你}|
- {1: }{n: 吗好可你}|
- {1: ~}|*9
- {2:-- }{5:match 1 of 9} |
- ]]
- screen:expect(pum_start_rl)
- feed('fo')
- screen:expect([[
- ^ of|
- {1: }{s: dnikoof o}{ms:of}|
- {1: }{n: dnikoof oofo}{mn:of}|
- {1: }{n: dnikoof rabo}{mn:of}|
- {1: }{n: dnikoof zaBo}{mn:of}|
- {1: }{n: dnikoof alabo}{mn:of}|
- {1: ~}|*13
- {2:-- }{5:match 1 of 9} |
- ]])
- feed('<Esc>S<C-X><C-O>')
- screen:expect(pum_start_rl)
- feed('你')
- screen:expect([[
- ^ 你|
- {1: }{s: 好}{ms:你}|
- {1: }{n: 吗好}{mn:你}|
- {1: }{n: 吗好不}{mn:你}|
- {1: }{n: 吗好可}{mn:你}|
- {1: ~}|*14
- {2:-- }{5:match 1 of 9} |
- ]])
- feed('吗')
- screen:expect([[
- ^ 吗你|
- {1: }{s: }{ms:吗}{s:好}{ms:你}|
- {1: }{n: }{mn:吗}{n:好不}{mn:你}|
- {1: }{n: }{mn:吗}{n:好可}{mn:你}|
- {1: ~}|*15
- {2:-- }{5:match 1 of 9} |
- ]])
- feed('<C-E><Esc>')
- command('set norightleft')
- command('set completeopt-=fuzzy')
- feed('S<C-X><C-O>')
- screen:expect(pum_start)
- feed('fo')
- screen:expect([[
- fo^ |
- {ms:fo}{s:o fookind }{1: }|
- {mn:fo}{n:ofoo fookind }{1: }|
- {mn:fo}{n:obar fookind }{1: }|
- {mn:fo}{n:oBaz fookind }{1: }|
- {mn:fo}{n:obala fookind }{1: }|
- {1:~ }|*13
- {2:-- }{5:match 1 of 9} |
- ]])
- feed('<C-E><Esc>')
- command('set rightleft')
- feed('S<C-X><C-O>')
- screen:expect(pum_start_rl)
- feed('fo')
- screen:expect([[
- ^ of|
- {1: }{s: dnikoof o}{ms:of}|
- {1: }{n: dnikoof oofo}{mn:of}|
- {1: }{n: dnikoof rabo}{mn:of}|
- {1: }{n: dnikoof zaBo}{mn:of}|
- {1: }{n: dnikoof alabo}{mn:of}|
- {1: ~}|*13
- {2:-- }{5:match 1 of 9} |
- ]])
- feed('<C-E><Esc>')
- command('set norightleft')
- feed('S<C-R>=Comp()<CR>f')
- screen:expect([[
- f^ |
- {ms:f}{s:oo }{1: }|
- {mn:F}{n:oobar }{1: }|
- {mn:f}{n:ooBaz }{1: }|
- {1:~ }|*15
- {2:-- INSERT --} |
- ]])
- feed('o<BS><C-R>=Comp()<CR>')
- screen:expect_unchanged(true)
- feed('<Esc>')
- command('set completeopt+=fuzzy,menu')
- feed('S hello helio hero h<C-X><C-P>')
- screen:expect([[
- hello helio hero h^ |
- {1:~ }{n: }{mn:h}{n:ello }{1: }|
- {1:~ }{n: }{mn:h}{n:elio }{1: }|
- {1:~ }{s: }{ms:h}{s:ero }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<Esc>S hello helio hero h<C-X><C-P><C-P>')
- screen:expect([[
- hello helio hero h^ |
- {1:~ }{n: }{mn:h}{n:ello }{1: }|
- {1:~ }{s: }{ms:h}{s:elio }{1: }|
- {1:~ }{n: }{mn:h}{n:ero }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 2 of 3} |
- ]])
- feed('<C-E><Esc>')
- end)
- -- oldtest: Test_pum_highlights_match_with_abbr()
- it('can highlight matched text with abbr', function()
- exec([[
- func Omni_test(findstart, base)
- if a:findstart
- return col(".")
- endif
- return {
- \ 'words': [
- \ { 'word': 'foobar', 'abbr': "foobar\t\t!" },
- \ { 'word': 'foobaz', 'abbr': "foobaz\t\t!" },
- \]}
- endfunc
- set omnifunc=Omni_test
- set completeopt=menuone,noinsert
- hi PmenuMatchSel guifg=Blue guibg=Grey
- hi PmenuMatch guifg=Blue guibg=Plum1
- ]])
- feed('i<C-X><C-O>')
- screen:expect([[
- ^ |
- {s:foobar ! }{1: }|
- {n:foobaz ! }{1: }|
- {1:~ }|*16
- {2:-- }{5:match 1 of 2} |
- ]])
- feed('foo')
- screen:expect([[
- foo^ |
- {ms:foo}{s:bar ! }{1: }|
- {mn:foo}{n:baz ! }{1: }|
- {1:~ }|*16
- {2:-- }{5:match 1 of 2} |
- ]])
- feed('<C-E><Esc>')
- end)
- -- oldtest: Test_pum_user_abbr_hlgroup()
- it('custom abbr_hlgroup override', function()
- exec([[
- let s:var = 0
- func CompleteFunc(findstart, base)
- if a:findstart
- return 0
- endif
- if s:var == 1
- return {
- \ 'words': [
- \ { 'word': 'aword1', 'abbr_hlgroup': 'StrikeFake' },
- \ { 'word': '你好', 'abbr_hlgroup': 'StrikeFake' },
- \]}
- endif
- return {
- \ 'words': [
- \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
- \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'W', },
- \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'W', 'abbr_hlgroup': 'StrikeFake' },
- \]}
- endfunc
- func ChangeVar()
- let s:var = 1
- endfunc
- set completeopt=menu
- set completefunc=CompleteFunc
- hi StrikeFake guifg=DarkRed
- func HlMatch()
- hi PmenuMatchSel guifg=Blue guibg=Grey gui=underline
- hi PmenuMatch guifg=Blue guibg=Plum1 gui=underline
- endfunc
- ]])
- feed('Saw<C-X><C-U>')
- screen:expect([[
- aword1^ |
- {ds:aword1}{s: W extra text 1 }{1: }|
- {n:aword2 W extra text 2 }{1: }|
- {dn:你好}{n: W extra text 3 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><Esc>')
- command('call HlMatch()')
- feed('Saw<C-X><C-U>')
- screen:expect([[
- aword1^ |
- {uds:aw}{ds:ord1}{s: W extra text 1 }{1: }|
- {umn:aw}{n:ord2 W extra text 2 }{1: }|
- {dn:你好}{n: W extra text 3 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-N>')
- screen:expect([[
- aword2^ |
- {udn:aw}{dn:ord1}{n: W extra text 1 }{1: }|
- {ums:aw}{s:ord2 W extra text 2 }{1: }|
- {dn:你好}{n: W extra text 3 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 2 of 3} |
- ]])
- feed('<C-E><Esc>')
- command('call ChangeVar()')
- feed('S<C-X><C-U>')
- screen:expect([[
- aword1^ |
- {ds:aword1}{s: }{1: }|
- {dn:你好}{n: }{1: }|
- {1:~ }|*16
- {2:-- }{5:match 1 of 2} |
- ]])
- feed('<C-E><Esc>')
- end)
- -- oldtest: Test_pum_user_kind_hlgroup()
- it('custom kind_hlgroup override', function()
- exec([[
- func CompleteFunc( findstart, base )
- if a:findstart
- return 0
- endif
- return {
- \ 'words': [
- \ { 'word': 'aword1', 'menu': 'extra text 1', 'kind': 'variable', 'kind_hlgroup': 'KindVar', 'abbr_hlgroup': 'StrikeFake' },
- \ { 'word': 'aword2', 'menu': 'extra text 2', 'kind': 'function', 'kind_hlgroup': 'KindFunc' },
- \ { 'word': '你好', 'menu': 'extra text 3', 'kind': 'class', 'kind_hlgroup': 'KindClass' },
- \]}
- endfunc
- set completeopt=menu
- set completefunc=CompleteFunc
- hi StrikeFake guifg=DarkRed
- hi KindVar guifg=DarkYellow
- hi KindFunc guifg=DarkBlue
- hi KindClass guifg=DarkGreen
- ]])
- local attr_ids = screen:get_default_attr_ids()
- attr_ids.kvs = { foreground = Screen.colors.DarkYellow, background = Screen.colors.Grey }
- attr_ids.kfn = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Plum1 }
- attr_ids.kcn = { foreground = Screen.colors.DarkGreen, background = Screen.colors.Plum1 }
- screen:set_default_attr_ids(attr_ids)
- feed('S<C-X><C-U>')
- screen:expect([[
- aword1^ |
- {ds:aword1}{s: }{kvs:variable}{s: extra text 1 }{1: }|
- {n:aword2 }{kfn:function}{n: extra text 2 }{1: }|
- {n:你好 }{kcn:class}{n: extra text 3 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><Esc>')
- end)
- -- oldtest: Test_pum_completeitemalign()
- it('completeitemalign option', function()
- screen:try_resize(30, 15)
- exec([[
- func Omni_test(findstart, base)
- if a:findstart
- return col(".")
- endif
- return {
- \ 'words': [
- \ { 'word': 'foo', 'kind': 'S', 'menu': 'menu' },
- \ { 'word': 'bar', 'kind': 'T', 'menu': 'menu' },
- \ { 'word': '你好', 'kind': 'C', 'menu': '中文' },
- \]}
- endfunc
- func Omni_long(findstart, base)
- if a:findstart
- return col(".")
- endif
- return {
- \ 'words': [
- \ { 'word': 'loooong_foo', 'kind': 'S', 'menu': 'menu' },
- \ { 'word': 'loooong_bar', 'kind': 'T', 'menu': 'menu' },
- \]}
- endfunc
- set omnifunc=Omni_test
- ]])
- -- T1
- command('set cia=abbr,kind,menu')
- feed('S<C-X><C-O>')
- screen:expect([[
- foo^ |
- {s:foo S menu }{1: }|
- {n:bar T menu }{1: }|
- {n:你好 C 中文 }{1: }|
- {1:~ }|*10
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><ESC>')
- -- T2
- command('set cia=abbr,menu,kind')
- feed('S<C-X><C-O>')
- screen:expect([[
- foo^ |
- {s:foo menu S }{1: }|
- {n:bar menu T }{1: }|
- {n:你好 中文 C }{1: }|
- {1:~ }|*10
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><ESC>')
- -- T3
- command('set cia=kind,abbr,menu')
- feed('S<C-X><C-O>')
- screen:expect([[
- foo^ |
- {s:S foo menu }{1: }|
- {n:T bar menu }{1: }|
- {n:C 你好 中文 }{1: }|
- {1:~ }|*10
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><ESC>')
- -- T4
- command('set cia=kind,menu,abbr')
- feed('S<C-X><C-O>')
- screen:expect([[
- foo^ |
- {s:S menu foo }{1: }|
- {n:T menu bar }{1: }|
- {n:C 中文 你好 }{1: }|
- {1:~ }|*10
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><ESC>')
- -- T5
- command('set cia=menu,abbr,kind')
- feed('S<C-X><C-O>')
- screen:expect([[
- foo^ |
- {s:menu foo S }{1: }|
- {n:menu bar T }{1: }|
- {n:中文 你好 C }{1: }|
- {1:~ }|*10
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><ESC>')
- -- T6
- command('set cia=menu,kind,abbr')
- feed('S<C-X><C-O>')
- screen:expect([[
- foo^ |
- {s:menu S foo }{1: }|
- {n:menu T bar }{1: }|
- {n:中文 C 你好 }{1: }|
- {1:~ }|*10
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><ESC>')
- -- T7
- command('set cia&')
- feed('S<C-X><C-O>')
- screen:expect([[
- foo^ |
- {s:foo S menu }{1: }|
- {n:bar T menu }{1: }|
- {n:你好 C 中文 }{1: }|
- {1:~ }|*10
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><ESC>')
- -- Test_pum_completeitemalign_07
- command('set cia=menu,kind,abbr columns=12 cmdheight=2 omnifunc=Omni_long')
- feed('S<C-X><C-O>')
- screen:expect([[
- loooong_foo^ |
- {s:menu S loooo}|
- {n:menu T loooo}|
- {1:~ }|*10
- |
- {2:--} |
- ]])
- feed('<C-E><ESC>')
- end)
- -- oldtest: Test_pum_matchins_highlight()
- it('with ComplMatchIns highlight', function()
- exec([[
- let g:change = 0
- func Omni_test(findstart, base)
- if a:findstart
- return col(".")
- endif
- if g:change == 0
- return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}]
- endif
- return [#{word: "foo", info: "info"}, #{word: "bar"}, #{word: "你好"}]
- endfunc
- set omnifunc=Omni_test
- hi ComplMatchIns guifg=red
- ]])
- feed('Sαβγ <C-X><C-O>')
- screen:expect([[
- αβγ {8:foo}^ |
- {1:~ }{s: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: 你好 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><Esc>')
- feed('Sαβγ <C-X><C-O><C-N>')
- screen:expect([[
- αβγ {8:bar}^ |
- {1:~ }{n: foo }{1: }|
- {1:~ }{s: bar }{1: }|
- {1:~ }{n: 你好 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 2 of 3} |
- ]])
- feed('<C-E><Esc>')
- feed('Sαβγ <C-X><C-O><C-N><C-N>')
- screen:expect([[
- αβγ {8:你好}^ |
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{s: 你好 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 3 of 3} |
- ]])
- feed('<C-E><Esc>')
- -- restore after accept
- feed('Sαβγ <C-X><C-O><C-Y>')
- screen:expect([[
- αβγ foo^ |
- {1:~ }|*18
- {2:-- INSERT --} |
- ]])
- feed('<Esc>')
- -- restore after cancel completion
- feed('Sαβγ <C-X><C-O><Space>')
- screen:expect([[
- αβγ foo ^ |
- {1:~ }|*18
- {2:-- INSERT --} |
- ]])
- feed('<Esc>')
- -- text after the inserted text shouldn't be highlighted
- feed('0ea <C-X><C-O>')
- screen:expect([[
- αβγ {8:foo}^ foo |
- {1:~ }{s: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: 你好 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-P>')
- screen:expect([[
- αβγ ^ foo |
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: 你好 }{1: }|
- {1:~ }|*15
- {2:-- }{8:Back at original} |
- ]])
- feed('<C-P>')
- screen:expect([[
- αβγ {8:你好}^ foo |
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{s: 你好 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 3 of 3} |
- ]])
- feed('<C-Y>')
- screen:expect([[
- αβγ 你好^ foo |
- {1:~ }|*18
- {2:-- INSERT --} |
- ]])
- feed('<Esc>')
- feed(':let g:change=1<CR>S<C-X><C-O>')
- screen:expect([[
- info |
- {1:~ }|*2
- {3:[Scratch] [Preview] }|
- {8:foo}^ |
- {s:foo }{1: }|
- {n:bar }{1: }|
- {n:你好 }{1: }|
- {1:~ }|*10
- {4:[No Name] [+] }|
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<Esc>')
- end)
- -- oldtest: Test_pum_matchins_highlight_combine()
- it('with ComplMatchIns, Normal and CursorLine highlights', function()
- exec([[
- func Omni_test(findstart, base)
- if a:findstart
- return col(".")
- endif
- return [#{word: "foo"}, #{word: "bar"}, #{word: "你好"}]
- endfunc
- set omnifunc=Omni_test
- hi Normal guibg=blue
- hi CursorLine guibg=green guifg=white
- set cursorline
- call setline(1, 'aaa bbb')
- ]])
- -- when ComplMatchIns is not set, CursorLine applies normally
- feed('0ea <C-X><C-O>')
- screen:expect([[
- {10:aaa foo^ bbb }|
- {1:~ }{s: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: 你好 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E>')
- screen:expect([[
- {10:aaa ^ bbb }|
- {1:~ }|*18
- {2:-- INSERT --} |
- ]])
- feed('<BS><Esc>')
- -- when ComplMatchIns is set, it is applied over CursorLine
- command('hi ComplMatchIns guifg=Yellow')
- feed('0ea <C-X><C-O>')
- screen:expect([[
- {10:aaa }{9:foo}{10:^ bbb }|
- {1:~ }{s: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: 你好 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-P>')
- screen:expect([[
- {10:aaa ^ bbb }|
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{n: 你好 }{1: }|
- {1:~ }|*15
- {2:-- }{8:Back at original} |
- ]])
- feed('<C-P>')
- screen:expect([[
- {10:aaa }{9:你好}{10:^ bbb }|
- {1:~ }{n: foo }{1: }|
- {1:~ }{n: bar }{1: }|
- {1:~ }{s: 你好 }{1: }|
- {1:~ }|*15
- {2:-- }{5:match 3 of 3} |
- ]])
- feed('<C-E>')
- screen:expect([[
- {10:aaa ^ bbb }|
- {1:~ }|*18
- {2:-- INSERT --} |
- ]])
- feed('<Esc>')
- -- Does not highlight the compl leader
- command('set cot+=menuone,noselect')
- feed('S<C-X><C-O>')
- local pum_start = [[
- {10:^ }|
- {n:foo }{1: }|
- {n:bar }{1: }|
- {n:你好 }{1: }|
- {1:~ }|*15
- {2:-- }{8:Back at original} |
- ]]
- screen:expect(pum_start)
- feed('f<C-N>')
- screen:expect([[
- {10:f}{9:oo}{10:^ }|
- {s:foo }{1: }|
- {1:~ }|*17
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><ESC>')
- command('set cot+=fuzzy')
- feed('S<C-X><C-O>')
- screen:expect(pum_start)
- feed('f<C-N>')
- screen:expect([[
- {10:foo^ }|
- {s:foo }{1: }|
- {1:~ }|*17
- {2:-- }{5:match 1 of 3} |
- ]])
- feed('<C-E><Esc>')
- command('set cot-=fuzzy')
- feed('Sf<C-N>')
- screen:expect([[
- {10:f^ }|
- {1:~ }|*18
- {2:-- }{6:Pattern not found} |
- ]])
- feed('<C-E><Esc>')
- end)
- end
- end
- describe('with ext_multigrid', function()
- with_ext_multigrid(true)
- end)
- describe('without ext_multigrid', function()
- with_ext_multigrid(false)
- end)
- end)
|