float_spec.lua 425 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local global_helpers = require('test.helpers')
  4. local os = require('os')
  5. local clear, feed = helpers.clear, helpers.feed
  6. local assert_alive = helpers.assert_alive
  7. local command, feed_command = helpers.command, helpers.feed_command
  8. local eval = helpers.eval
  9. local eq = helpers.eq
  10. local neq = helpers.neq
  11. local expect = helpers.expect
  12. local exec = helpers.exec
  13. local exec_lua = helpers.exec_lua
  14. local insert = helpers.insert
  15. local meths = helpers.meths
  16. local curbufmeths = helpers.curbufmeths
  17. local funcs = helpers.funcs
  18. local run = helpers.run
  19. local pcall_err = helpers.pcall_err
  20. local tbl_contains = global_helpers.tbl_contains
  21. local curbuf, curwin, curtab = helpers.curbuf, helpers.curwin, helpers.curtab
  22. local NIL = helpers.NIL
  23. describe('float window', function()
  24. before_each(function()
  25. clear()
  26. command('hi VertSplit gui=reverse')
  27. end)
  28. it('behavior', function()
  29. -- Create three windows and test that ":wincmd <direction>" changes to the
  30. -- first window, if the previous window is invalid.
  31. command('split')
  32. meths.open_win(0, true, {width=10, height=10, relative='editor', row=0, col=0})
  33. eq(1002, funcs.win_getid())
  34. eq('editor', meths.win_get_config(1002).relative)
  35. command([[
  36. call nvim_win_close(1001, v:false)
  37. wincmd j
  38. ]])
  39. eq(1000, funcs.win_getid())
  40. end)
  41. it('win_execute() should work' , function()
  42. local buf = meths.create_buf(false, false)
  43. meths.buf_set_lines(buf, 0, -1, true, {'the floatwin', 'abc', 'def'})
  44. local win = meths.open_win(buf, false, {relative='win', width=16, height=1, row=0, col=10})
  45. local line = funcs.win_execute(win, 'echo getline(1)')
  46. eq('\nthe floatwin', line)
  47. eq('\n1', funcs.win_execute(win, 'echo line(".",'..win.id..')'))
  48. eq('\n3', funcs.win_execute(win, 'echo line("$",'..win.id..')'))
  49. eq('\n0', funcs.win_execute(win, 'echo line("$", 123456)'))
  50. funcs.win_execute(win, 'bwipe!')
  51. end)
  52. it("win_execute() call commands that are not allowed when 'hidden' is not set" , function()
  53. command('set nohidden')
  54. local buf = meths.create_buf(false, false)
  55. meths.buf_set_lines(buf, 0, -1, true, {'the floatwin'})
  56. local win = meths.open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10})
  57. eq('Vim(close):E37: No write since last change (add ! to override)', pcall_err(funcs.win_execute, win, 'close'))
  58. eq('Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)', pcall_err(funcs.win_execute, win, 'bdelete'))
  59. funcs.win_execute(win, 'bwipe!')
  60. end)
  61. it('closed immediately by autocmd #11383', function()
  62. eq('Window was closed immediately',
  63. pcall_err(exec_lua, [[
  64. local api = vim.api
  65. local function crashes(contents)
  66. local buf = api.nvim_create_buf(false, true)
  67. local floatwin = api.nvim_open_win(buf, true, {
  68. relative = 'cursor';
  69. style = 'minimal';
  70. row = 0; col = 0;
  71. height = #contents;
  72. width = 10;
  73. })
  74. api.nvim_buf_set_lines(buf, 0, -1, true, contents)
  75. local winnr = vim.fn.win_id2win(floatwin)
  76. api.nvim_command('wincmd p')
  77. api.nvim_command('autocmd CursorMoved * ++once '..winnr..'wincmd c')
  78. return buf, floatwin
  79. end
  80. crashes{'foo'}
  81. crashes{'bar'}
  82. ]]))
  83. assert_alive()
  84. end)
  85. it('closed immediately by autocmd after win_enter #15548', function()
  86. eq('Window was closed immediately',
  87. pcall_err(exec_lua, [[
  88. vim.cmd "autocmd BufLeave * ++once quit!"
  89. local buf = vim.api.nvim_create_buf(true, true)
  90. vim.api.nvim_open_win(buf, true, {
  91. relative = "win",
  92. row = 0, col = 0,
  93. width = 1, height = 1,
  94. noautocmd = false,
  95. })
  96. ]]))
  97. assert_alive()
  98. end)
  99. it('opened with correct height', function()
  100. local height = exec_lua([[
  101. vim.api.nvim_set_option("winheight", 20)
  102. local bufnr = vim.api.nvim_create_buf(false, true)
  103. local opts = {
  104. height = 10,
  105. col = 5,
  106. row = 1,
  107. relative = 'editor',
  108. style = 'minimal',
  109. width = 15
  110. }
  111. local win_id = vim.api.nvim_open_win(bufnr, true, opts)
  112. return vim.api.nvim_win_get_height(win_id)
  113. ]])
  114. eq(10, height)
  115. end)
  116. it('opened with correct width', function()
  117. local width = exec_lua([[
  118. vim.api.nvim_set_option("winwidth", 20)
  119. local bufnr = vim.api.nvim_create_buf(false, true)
  120. local opts = {
  121. height = 10,
  122. col = 5,
  123. row = 1,
  124. relative = 'editor',
  125. style = 'minimal',
  126. width = 10
  127. }
  128. local win_id = vim.api.nvim_open_win(bufnr, true, opts)
  129. return vim.api.nvim_win_get_width(win_id)
  130. ]])
  131. eq(10, width)
  132. end)
  133. it('opened with correct position', function()
  134. local pos = exec_lua([[
  135. local bufnr = vim.api.nvim_create_buf(false, true)
  136. local opts = {
  137. width = 10,
  138. height = 10,
  139. col = 7,
  140. row = 9,
  141. relative = 'editor',
  142. style = 'minimal'
  143. }
  144. local win_id = vim.api.nvim_open_win(bufnr, false, opts)
  145. return vim.api.nvim_win_get_position(win_id)
  146. ]])
  147. eq(9, pos[1])
  148. eq(7, pos[2])
  149. end)
  150. it('opened with correct position relative to the mouse', function()
  151. meths.input_mouse('left', 'press', '', 0, 10, 10)
  152. local pos = exec_lua([[
  153. local bufnr = vim.api.nvim_create_buf(false, true)
  154. local opts = {
  155. width = 10,
  156. height = 10,
  157. col = 1,
  158. row = 2,
  159. relative = 'mouse',
  160. style = 'minimal'
  161. }
  162. local win_id = vim.api.nvim_open_win(bufnr, false, opts)
  163. return vim.api.nvim_win_get_position(win_id)
  164. ]])
  165. eq(12, pos[1])
  166. eq(11, pos[2])
  167. end)
  168. it('opened with correct position relative to the cursor', function()
  169. local pos = exec_lua([[
  170. local bufnr = vim.api.nvim_create_buf(false, true)
  171. local opts = {
  172. width = 10,
  173. height = 10,
  174. col = 7,
  175. row = 9,
  176. relative = 'cursor',
  177. style = 'minimal'
  178. }
  179. local win_id = vim.api.nvim_open_win(bufnr, false, opts)
  180. return vim.api.nvim_win_get_position(win_id)
  181. ]])
  182. eq(9, pos[1])
  183. eq(7, pos[2])
  184. end)
  185. it('opened with correct position relative to another window', function()
  186. local pos = exec_lua([[
  187. local bufnr = vim.api.nvim_create_buf(false, true)
  188. local par_opts = {
  189. width = 50,
  190. height = 50,
  191. col = 7,
  192. row = 9,
  193. relative = 'editor',
  194. style = 'minimal'
  195. }
  196. local par_win_id = vim.api.nvim_open_win(bufnr, false, par_opts)
  197. local opts = {
  198. width = 10,
  199. height = 10,
  200. col = 7,
  201. row = 9,
  202. relative = 'win',
  203. style = 'minimal',
  204. win = par_win_id
  205. }
  206. local win_id = vim.api.nvim_open_win(bufnr, false, opts)
  207. return vim.api.nvim_win_get_position(win_id)
  208. ]])
  209. eq(18, pos[1])
  210. eq(14, pos[2])
  211. end)
  212. it('opened with correct position relative to another relative window', function()
  213. local pos = exec_lua([[
  214. local bufnr = vim.api.nvim_create_buf(false, true)
  215. local root_opts = {
  216. width = 50,
  217. height = 50,
  218. col = 7,
  219. row = 9,
  220. relative = 'editor',
  221. style = 'minimal'
  222. }
  223. local root_win_id = vim.api.nvim_open_win(bufnr, false, root_opts)
  224. local par_opts = {
  225. width = 20,
  226. height = 20,
  227. col = 2,
  228. row = 3,
  229. relative = 'win',
  230. win = root_win_id,
  231. style = 'minimal'
  232. }
  233. local par_win_id = vim.api.nvim_open_win(bufnr, false, par_opts)
  234. local opts = {
  235. width = 10,
  236. height = 10,
  237. col = 3,
  238. row = 2,
  239. relative = 'win',
  240. win = par_win_id,
  241. style = 'minimal'
  242. }
  243. local win_id = vim.api.nvim_open_win(bufnr, false, opts)
  244. return vim.api.nvim_win_get_position(win_id)
  245. ]])
  246. eq(14, pos[1])
  247. eq(12, pos[2])
  248. end)
  249. it('is not operated on by windo when non-focusable #15374', function()
  250. command([[
  251. let winids = []
  252. windo call add(winids, win_getid())
  253. ]])
  254. local windo_count_before = eval('len(winids)')
  255. local winid = exec_lua([[
  256. local bufnr = vim.api.nvim_create_buf(false, true)
  257. local opts = {
  258. relative = 'editor',
  259. focusable = false,
  260. height = 5,
  261. width = 5,
  262. col = 5,
  263. row = 5,
  264. }
  265. return vim.api.nvim_open_win(bufnr, false, opts)
  266. ]])
  267. command([[
  268. let winids = []
  269. windo call add(winids, win_getid())
  270. ]])
  271. local windo_count_after = eval('len(winids)')
  272. eq(windo_count_before, windo_count_after)
  273. eq(false, tbl_contains(eval('winids'), winid))
  274. end)
  275. it('is operated on by windo when focusable', function()
  276. command([[
  277. let winids = []
  278. windo call add(winids, win_getid())
  279. ]])
  280. local windo_count_before = eval('len(winids)')
  281. local winid = exec_lua([[
  282. local bufnr = vim.api.nvim_create_buf(false, true)
  283. local opts = {
  284. relative = 'editor',
  285. focusable = true,
  286. height = 5,
  287. width = 5,
  288. col = 5,
  289. row = 5,
  290. }
  291. return vim.api.nvim_open_win(bufnr, false, opts)
  292. ]])
  293. command([[
  294. let winids = []
  295. windo call add(winids, win_getid())
  296. ]])
  297. local windo_count_after = eval('len(winids)')
  298. eq(windo_count_before + 1, windo_count_after)
  299. eq(true, tbl_contains(eval('winids'), winid))
  300. end)
  301. it('is not active after windo when non-focusable #15374', function()
  302. local winid = exec_lua([[
  303. local bufnr = vim.api.nvim_create_buf(false, true)
  304. local opts = {
  305. relative = 'editor',
  306. focusable = false,
  307. height = 5,
  308. width = 5,
  309. col = 5,
  310. row = 5,
  311. }
  312. return vim.api.nvim_open_win(bufnr, false, opts)
  313. ]])
  314. command('windo echo')
  315. neq(winid, eval('win_getid()'))
  316. end)
  317. it('is active after windo when focusable', function()
  318. local winid = exec_lua([[
  319. local bufnr = vim.api.nvim_create_buf(false, true)
  320. local opts = {
  321. relative = 'editor',
  322. focusable = true,
  323. height = 5,
  324. width = 5,
  325. col = 5,
  326. row = 5,
  327. }
  328. return vim.api.nvim_open_win(bufnr, false, opts)
  329. ]])
  330. command('windo echo')
  331. eq(winid, eval('win_getid()'))
  332. end)
  333. it('supports windo with focusable and non-focusable floats', function()
  334. local winids = exec_lua([[
  335. local result = {vim.api.nvim_get_current_win()}
  336. local bufnr = vim.api.nvim_create_buf(false, true)
  337. local opts = {
  338. relative = 'editor',
  339. focusable = false,
  340. height = 5,
  341. width = 5,
  342. col = 5,
  343. row = 5,
  344. }
  345. vim.api.nvim_open_win(bufnr, false, opts)
  346. opts.focusable = true
  347. table.insert(result, vim.api.nvim_open_win(bufnr, false, opts))
  348. opts.focusable = false
  349. vim.api.nvim_open_win(bufnr, false, opts)
  350. opts.focusable = true
  351. table.insert(result, vim.api.nvim_open_win(bufnr, false, opts))
  352. opts.focusable = false
  353. vim.api.nvim_open_win(bufnr, false, opts)
  354. return result
  355. ]])
  356. table.sort(winids)
  357. command([[
  358. let winids = []
  359. windo call add(winids, win_getid())
  360. call sort(winids)
  361. ]])
  362. eq(winids, eval('winids'))
  363. end)
  364. it('no crash with bufpos and non-existent window', function()
  365. command('new')
  366. local closed_win = meths.get_current_win().id
  367. command('close')
  368. local buf = meths.create_buf(false,false)
  369. meths.open_win(buf, true, {relative='win', win=closed_win, width=1, height=1, bufpos={0,0}})
  370. assert_alive()
  371. end)
  372. it("no segfault when setting minimal style after clearing local 'fillchars' #19510", function()
  373. local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
  374. local float_win = meths.open_win(0, true, float_opts)
  375. meths.win_set_option(float_win, 'fillchars', NIL)
  376. float_opts.style = 'minimal'
  377. meths.win_set_config(float_win, float_opts)
  378. assert_alive()
  379. end)
  380. it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function()
  381. meths.set_option('splitkeep', 'screen')
  382. local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10}
  383. local float_win = meths.open_win(0, true, float_opts)
  384. eq(5, meths.win_get_option(float_win, 'scroll'))
  385. end)
  386. it(':unhide works when there are floating windows', function()
  387. local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5}
  388. local w0 = curwin()
  389. meths.open_win(0, false, float_opts)
  390. meths.open_win(0, false, float_opts)
  391. eq(3, #meths.list_wins())
  392. command('unhide')
  393. eq({ w0 }, meths.list_wins())
  394. end)
  395. it(':all works when there are floating windows', function()
  396. command('args Xa.txt')
  397. local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5}
  398. local w0 = curwin()
  399. meths.open_win(0, false, float_opts)
  400. meths.open_win(0, false, float_opts)
  401. eq(3, #meths.list_wins())
  402. command('all')
  403. eq({ w0 }, meths.list_wins())
  404. end)
  405. describe('with only one tabpage,', function()
  406. local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
  407. local old_buf, old_win
  408. before_each(function()
  409. insert('foo')
  410. old_buf = curbuf().id
  411. old_win = curwin().id
  412. end)
  413. describe('closing the last non-floating window gives E444', function()
  414. before_each(function()
  415. meths.open_win(old_buf, true, float_opts)
  416. end)
  417. it('if called from non-floating window', function()
  418. meths.set_current_win(old_win)
  419. eq('Vim:E444: Cannot close last window',
  420. pcall_err(meths.win_close, old_win, false))
  421. end)
  422. it('if called from floating window', function()
  423. eq('Vim:E444: Cannot close last window',
  424. pcall_err(meths.win_close, old_win, false))
  425. end)
  426. end)
  427. describe("deleting the last non-floating window's buffer", function()
  428. describe('leaves one window with an empty buffer when there is only one buffer', function()
  429. local same_buf_float
  430. before_each(function()
  431. same_buf_float = meths.open_win(old_buf, false, float_opts).id
  432. end)
  433. after_each(function()
  434. eq(old_win, curwin().id)
  435. expect('')
  436. eq(1, #meths.list_wins())
  437. end)
  438. it('if called from non-floating window', function()
  439. meths.buf_delete(old_buf, {force = true})
  440. end)
  441. it('if called from floating window', function()
  442. meths.set_current_win(same_buf_float)
  443. command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')
  444. command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')
  445. meths.buf_delete(old_buf, {force = true})
  446. eq(same_buf_float, eval('g:win_leave'))
  447. eq(old_win, eval('g:win_enter'))
  448. end)
  449. end)
  450. describe('closes other windows with that buffer when there are other buffers', function()
  451. local same_buf_float, other_buf, other_buf_float
  452. before_each(function()
  453. same_buf_float = meths.open_win(old_buf, false, float_opts).id
  454. other_buf = meths.create_buf(true, false).id
  455. other_buf_float = meths.open_win(other_buf, true, float_opts).id
  456. insert('bar')
  457. meths.set_current_win(old_win)
  458. end)
  459. after_each(function()
  460. eq(other_buf, curbuf().id)
  461. expect('bar')
  462. eq(2, #meths.list_wins())
  463. end)
  464. it('if called from non-floating window', function()
  465. meths.buf_delete(old_buf, {force = true})
  466. eq(old_win, curwin().id)
  467. end)
  468. it('if called from floating window with the same buffer', function()
  469. meths.set_current_win(same_buf_float)
  470. command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')
  471. command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')
  472. meths.buf_delete(old_buf, {force = true})
  473. eq(same_buf_float, eval('g:win_leave'))
  474. eq(old_win, eval('g:win_enter'))
  475. eq(old_win, curwin().id)
  476. end)
  477. -- TODO: this case is too hard to deal with
  478. pending('if called from floating window with another buffer', function()
  479. meths.set_current_win(other_buf_float)
  480. meths.buf_delete(old_buf, {force = true})
  481. end)
  482. end)
  483. describe('creates an empty buffer when there is only one listed buffer', function()
  484. local same_buf_float, unlisted_buf_float
  485. before_each(function()
  486. same_buf_float = meths.open_win(old_buf, false, float_opts).id
  487. local unlisted_buf = meths.create_buf(true, false).id
  488. unlisted_buf_float = meths.open_win(unlisted_buf, true, float_opts).id
  489. insert('unlisted')
  490. command('set nobuflisted')
  491. meths.set_current_win(old_win)
  492. end)
  493. after_each(function()
  494. expect('')
  495. eq(2, #meths.list_wins())
  496. end)
  497. it('if called from non-floating window', function()
  498. meths.buf_delete(old_buf, {force = true})
  499. eq(old_win, curwin().id)
  500. end)
  501. it('if called from floating window with the same buffer', function()
  502. meths.set_current_win(same_buf_float)
  503. command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')
  504. command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')
  505. meths.buf_delete(old_buf, {force = true})
  506. eq(same_buf_float, eval('g:win_leave'))
  507. eq(old_win, eval('g:win_enter'))
  508. eq(old_win, curwin().id)
  509. end)
  510. -- TODO: this case is too hard to deal with
  511. pending('if called from floating window with an unlisted buffer', function()
  512. meths.set_current_win(unlisted_buf_float)
  513. meths.buf_delete(old_buf, {force = true})
  514. end)
  515. end)
  516. end)
  517. describe('with splits, deleting the last listed buffer creates an empty buffer', function()
  518. describe('when a non-floating window has an unlisted buffer', function()
  519. local same_buf_float
  520. before_each(function()
  521. command('botright vnew')
  522. insert('unlisted')
  523. command('set nobuflisted')
  524. meths.set_current_win(old_win)
  525. same_buf_float = meths.open_win(old_buf, false, float_opts).id
  526. end)
  527. after_each(function()
  528. expect('')
  529. eq(2, #meths.list_wins())
  530. end)
  531. it('if called from non-floating window with the deleted buffer', function()
  532. meths.buf_delete(old_buf, {force = true})
  533. eq(old_win, curwin().id)
  534. end)
  535. it('if called from floating window with the deleted buffer', function()
  536. meths.set_current_win(same_buf_float)
  537. meths.buf_delete(old_buf, {force = true})
  538. eq(same_buf_float, curwin().id)
  539. end)
  540. end)
  541. end)
  542. end)
  543. describe('with multiple tabpages but only one listed buffer,', function()
  544. local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
  545. local unlisted_buf, old_buf, old_win
  546. before_each(function()
  547. insert('unlisted')
  548. command('set nobuflisted')
  549. unlisted_buf = curbuf().id
  550. command('tabnew')
  551. insert('foo')
  552. old_buf = curbuf().id
  553. old_win = curwin().id
  554. end)
  555. describe('without splits, deleting the last listed buffer creates an empty buffer', function()
  556. local same_buf_float
  557. before_each(function()
  558. meths.set_current_win(old_win)
  559. same_buf_float = meths.open_win(old_buf, false, float_opts).id
  560. end)
  561. after_each(function()
  562. expect('')
  563. eq(2, #meths.list_wins())
  564. eq(2, #meths.list_tabpages())
  565. end)
  566. it('if called from non-floating window', function()
  567. meths.buf_delete(old_buf, {force = true})
  568. eq(old_win, curwin().id)
  569. end)
  570. it('if called from non-floating window in another tabpage', function()
  571. command('tab split')
  572. eq(3, #meths.list_tabpages())
  573. meths.buf_delete(old_buf, {force = true})
  574. end)
  575. it('if called from floating window with the same buffer', function()
  576. meths.set_current_win(same_buf_float)
  577. command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')
  578. command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')
  579. meths.buf_delete(old_buf, {force = true})
  580. eq(same_buf_float, eval('g:win_leave'))
  581. eq(old_win, eval('g:win_enter'))
  582. eq(old_win, curwin().id)
  583. end)
  584. end)
  585. describe('with splits, deleting the last listed buffer creates an empty buffer', function()
  586. local same_buf_float
  587. before_each(function()
  588. command('botright vsplit')
  589. meths.set_current_buf(unlisted_buf)
  590. meths.set_current_win(old_win)
  591. same_buf_float = meths.open_win(old_buf, false, float_opts).id
  592. end)
  593. after_each(function()
  594. expect('')
  595. eq(3, #meths.list_wins())
  596. eq(2, #meths.list_tabpages())
  597. end)
  598. it('if called from non-floating window with the deleted buffer', function()
  599. meths.buf_delete(old_buf, {force = true})
  600. eq(old_win, curwin().id)
  601. end)
  602. it('if called from floating window with the deleted buffer', function()
  603. meths.set_current_win(same_buf_float)
  604. meths.buf_delete(old_buf, {force = true})
  605. eq(same_buf_float, curwin().id)
  606. end)
  607. end)
  608. end)
  609. describe('with multiple tabpages and multiple listed buffers,', function()
  610. local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
  611. local old_tabpage, old_buf, old_win
  612. before_each(function()
  613. old_tabpage = curtab().id
  614. insert('oldtab')
  615. command('tabnew')
  616. old_buf = curbuf().id
  617. old_win = curwin().id
  618. end)
  619. describe('closing the last non-floating window', function()
  620. describe('closes the tabpage when all floating windows are closeable', function()
  621. local same_buf_float
  622. before_each(function()
  623. same_buf_float = meths.open_win(old_buf, false, float_opts).id
  624. end)
  625. after_each(function()
  626. eq(old_tabpage, curtab().id)
  627. expect('oldtab')
  628. eq(1, #meths.list_tabpages())
  629. end)
  630. it('if called from non-floating window', function()
  631. meths.win_close(old_win, false)
  632. end)
  633. it('if called from floating window', function()
  634. meths.set_current_win(same_buf_float)
  635. meths.win_close(old_win, false)
  636. end)
  637. end)
  638. describe('gives E5601 when there are non-closeable floating windows', function()
  639. local other_buf_float
  640. before_each(function()
  641. command('set nohidden')
  642. local other_buf = meths.create_buf(true, false).id
  643. other_buf_float = meths.open_win(other_buf, true, float_opts).id
  644. insert('foo')
  645. meths.set_current_win(old_win)
  646. end)
  647. it('if called from non-floating window', function()
  648. eq('Vim:E5601: Cannot close window, only floating window would remain',
  649. pcall_err(meths.win_close, old_win, false))
  650. end)
  651. it('if called from floating window', function()
  652. meths.set_current_win(other_buf_float)
  653. eq('Vim:E5601: Cannot close window, only floating window would remain',
  654. pcall_err(meths.win_close, old_win, false))
  655. end)
  656. end)
  657. end)
  658. describe("deleting the last non-floating window's buffer", function()
  659. describe('closes the tabpage when all floating windows are closeable', function()
  660. local same_buf_float, other_buf, other_buf_float
  661. before_each(function()
  662. same_buf_float = meths.open_win(old_buf, false, float_opts).id
  663. other_buf = meths.create_buf(true, false).id
  664. other_buf_float = meths.open_win(other_buf, true, float_opts).id
  665. meths.set_current_win(old_win)
  666. end)
  667. after_each(function()
  668. eq(old_tabpage, curtab().id)
  669. expect('oldtab')
  670. eq(1, #meths.list_tabpages())
  671. end)
  672. it('if called from non-floating window', function()
  673. meths.buf_delete(old_buf, {force = false})
  674. end)
  675. it('if called from floating window with the same buffer', function()
  676. meths.set_current_win(same_buf_float)
  677. meths.buf_delete(old_buf, {force = false})
  678. end)
  679. -- TODO: this case is too hard to deal with
  680. pending('if called from floating window with another buffer', function()
  681. meths.set_current_win(other_buf_float)
  682. meths.buf_delete(old_buf, {force = false})
  683. end)
  684. end)
  685. -- TODO: what to do when there are non-closeable floating windows?
  686. end)
  687. end)
  688. local function with_ext_multigrid(multigrid)
  689. local screen, attrs
  690. before_each(function()
  691. screen = Screen.new(40,7)
  692. screen:attach {ext_multigrid=multigrid}
  693. attrs = {
  694. [0] = {bold=true, foreground=Screen.colors.Blue},
  695. [1] = {background = Screen.colors.LightMagenta},
  696. [2] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1},
  697. [3] = {bold = true},
  698. [4] = {bold = true, reverse = true},
  699. [5] = {reverse = true},
  700. [6] = {background = Screen.colors.LightMagenta, bold = true, reverse = true},
  701. [7] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  702. [8] = {bold = true, foreground = Screen.colors.SeaGreen4},
  703. [9] = {background = Screen.colors.LightGrey, underline = true},
  704. [10] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta},
  705. [11] = {bold = true, foreground = Screen.colors.Magenta},
  706. [12] = {background = Screen.colors.Red, bold = true, foreground = Screen.colors.Blue1},
  707. [13] = {background = Screen.colors.WebGray},
  708. [14] = {foreground = Screen.colors.Brown},
  709. [15] = {background = Screen.colors.Grey20},
  710. [16] = {background = Screen.colors.Grey20, bold = true, foreground = Screen.colors.Blue1},
  711. [17] = {background = Screen.colors.Yellow},
  712. [18] = {foreground = Screen.colors.Brown, background = Screen.colors.Grey20},
  713. [19] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
  714. [20] = {bold = true, foreground = Screen.colors.Brown},
  715. [21] = {background = Screen.colors.Gray90},
  716. [22] = {background = Screen.colors.LightRed},
  717. [23] = {foreground = Screen.colors.Black, background = Screen.colors.White};
  718. [24] = {foreground = Screen.colors.Black, background = Screen.colors.Grey80};
  719. [25] = {blend = 100, background = Screen.colors.Gray0};
  720. [26] = {blend = 80, background = Screen.colors.Gray0};
  721. [27] = {background = Screen.colors.LightGray};
  722. [28] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray};
  723. }
  724. screen:set_default_attr_ids(attrs)
  725. end)
  726. it('can be created and reconfigured', function()
  727. local buf = meths.create_buf(false,false)
  728. local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
  729. local expected_pos = {
  730. [4]={{id=1001}, 'NW', 1, 2, 5, true},
  731. }
  732. if multigrid then
  733. screen:expect{grid=[[
  734. ## grid 1
  735. [2:----------------------------------------]|
  736. [2:----------------------------------------]|
  737. [2:----------------------------------------]|
  738. [2:----------------------------------------]|
  739. [2:----------------------------------------]|
  740. [2:----------------------------------------]|
  741. [3:----------------------------------------]|
  742. ## grid 2
  743. ^ |
  744. {0:~ }|
  745. {0:~ }|
  746. {0:~ }|
  747. {0:~ }|
  748. {0:~ }|
  749. ## grid 3
  750. |
  751. ## grid 4
  752. {1: }|
  753. {2:~ }|
  754. ]], float_pos=expected_pos}
  755. else
  756. screen:expect([[
  757. ^ |
  758. {0:~ }|
  759. {0:~ }{1: }{0: }|
  760. {0:~ }{2:~ }{0: }|
  761. {0:~ }|
  762. {0:~ }|
  763. |
  764. ]])
  765. end
  766. meths.win_set_config(win, {relative='editor', row=0, col=10})
  767. expected_pos[4][4] = 0
  768. expected_pos[4][5] = 10
  769. if multigrid then
  770. screen:expect{grid=[[
  771. ## grid 1
  772. [2:----------------------------------------]|
  773. [2:----------------------------------------]|
  774. [2:----------------------------------------]|
  775. [2:----------------------------------------]|
  776. [2:----------------------------------------]|
  777. [2:----------------------------------------]|
  778. [3:----------------------------------------]|
  779. ## grid 2
  780. ^ |
  781. {0:~ }|
  782. {0:~ }|
  783. {0:~ }|
  784. {0:~ }|
  785. {0:~ }|
  786. ## grid 3
  787. |
  788. ## grid 4
  789. {1: }|
  790. {2:~ }|
  791. ]], float_pos=expected_pos}
  792. else
  793. screen:expect([[
  794. ^ {1: } |
  795. {0:~ }{2:~ }{0: }|
  796. {0:~ }|
  797. {0:~ }|
  798. {0:~ }|
  799. {0:~ }|
  800. |
  801. ]])
  802. end
  803. meths.win_close(win, false)
  804. if multigrid then
  805. screen:expect([[
  806. ## grid 1
  807. [2:----------------------------------------]|
  808. [2:----------------------------------------]|
  809. [2:----------------------------------------]|
  810. [2:----------------------------------------]|
  811. [2:----------------------------------------]|
  812. [2:----------------------------------------]|
  813. [3:----------------------------------------]|
  814. ## grid 2
  815. ^ |
  816. {0:~ }|
  817. {0:~ }|
  818. {0:~ }|
  819. {0:~ }|
  820. {0:~ }|
  821. ## grid 3
  822. |
  823. ]])
  824. else
  825. screen:expect([[
  826. ^ |
  827. {0:~ }|
  828. {0:~ }|
  829. {0:~ }|
  830. {0:~ }|
  831. {0:~ }|
  832. |
  833. ]])
  834. end
  835. end)
  836. it('draws correctly with redrawdebug=compositor', function()
  837. -- NB: we do not test that it produces the "correct" debug info
  838. -- (as it is intermediate only, and is allowed to change by internal
  839. -- refactors). Only check that it doesn't cause permanent glitches,
  840. -- or something.
  841. command("set redrawdebug=compositor")
  842. command("set wd=1")
  843. local buf = meths.create_buf(false,false)
  844. local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
  845. local expected_pos = {
  846. [4]={{id=1001}, 'NW', 1, 2, 5, true},
  847. }
  848. if multigrid then
  849. screen:expect{grid=[[
  850. ## grid 1
  851. [2:----------------------------------------]|
  852. [2:----------------------------------------]|
  853. [2:----------------------------------------]|
  854. [2:----------------------------------------]|
  855. [2:----------------------------------------]|
  856. [2:----------------------------------------]|
  857. [3:----------------------------------------]|
  858. ## grid 2
  859. ^ |
  860. {0:~ }|
  861. {0:~ }|
  862. {0:~ }|
  863. {0:~ }|
  864. {0:~ }|
  865. ## grid 3
  866. |
  867. ## grid 4
  868. {1: }|
  869. {2:~ }|
  870. ]], float_pos=expected_pos}
  871. else
  872. screen:expect([[
  873. ^ |
  874. {0:~ }|
  875. {0:~ }{1: }{0: }|
  876. {0:~ }{2:~ }{0: }|
  877. {0:~ }|
  878. {0:~ }|
  879. |
  880. ]])
  881. end
  882. meths.win_set_config(win, {relative='editor', row=0, col=10})
  883. expected_pos[4][4] = 0
  884. expected_pos[4][5] = 10
  885. if multigrid then
  886. screen:expect{grid=[[
  887. ## grid 1
  888. [2:----------------------------------------]|
  889. [2:----------------------------------------]|
  890. [2:----------------------------------------]|
  891. [2:----------------------------------------]|
  892. [2:----------------------------------------]|
  893. [2:----------------------------------------]|
  894. [3:----------------------------------------]|
  895. ## grid 2
  896. ^ |
  897. {0:~ }|
  898. {0:~ }|
  899. {0:~ }|
  900. {0:~ }|
  901. {0:~ }|
  902. ## grid 3
  903. |
  904. ## grid 4
  905. {1: }|
  906. {2:~ }|
  907. ]], float_pos=expected_pos}
  908. else
  909. screen:expect([[
  910. ^ {1: } |
  911. {0:~ }{2:~ }{0: }|
  912. {0:~ }|
  913. {0:~ }|
  914. {0:~ }|
  915. {0:~ }|
  916. |
  917. ]])
  918. end
  919. meths.win_close(win, false)
  920. if multigrid then
  921. screen:expect([[
  922. ## grid 1
  923. [2:----------------------------------------]|
  924. [2:----------------------------------------]|
  925. [2:----------------------------------------]|
  926. [2:----------------------------------------]|
  927. [2:----------------------------------------]|
  928. [2:----------------------------------------]|
  929. [3:----------------------------------------]|
  930. ## grid 2
  931. ^ |
  932. {0:~ }|
  933. {0:~ }|
  934. {0:~ }|
  935. {0:~ }|
  936. {0:~ }|
  937. ## grid 3
  938. |
  939. ]])
  940. else
  941. screen:expect([[
  942. ^ |
  943. {0:~ }|
  944. {0:~ }|
  945. {0:~ }|
  946. {0:~ }|
  947. {0:~ }|
  948. |
  949. ]])
  950. end
  951. end)
  952. it('return their configuration', function()
  953. local buf = meths.create_buf(false, false)
  954. local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=3, col=5, zindex=60})
  955. local expected = {anchor='NW', col=5, external=false, focusable=true, height=2, relative='editor', row=3, width=20, zindex=60}
  956. eq(expected, meths.win_get_config(win))
  957. eq({relative='', external=false, focusable=true}, meths.win_get_config(0))
  958. if multigrid then
  959. meths.win_set_config(win, {external=true, width=10, height=1})
  960. eq({external=true,focusable=true,width=10,height=1,relative=''}, meths.win_get_config(win))
  961. end
  962. end)
  963. it('defaults to NormalFloat highlight and inherited options', function()
  964. command('set number')
  965. command('hi NormalFloat guibg=#333333')
  966. feed('ix<cr>y<cr><esc>gg')
  967. local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10})
  968. if multigrid then
  969. screen:expect{grid=[[
  970. ## grid 1
  971. [2:----------------------------------------]|
  972. [2:----------------------------------------]|
  973. [2:----------------------------------------]|
  974. [2:----------------------------------------]|
  975. [2:----------------------------------------]|
  976. [2:----------------------------------------]|
  977. [3:----------------------------------------]|
  978. ## grid 2
  979. {14: 1 }^x |
  980. {14: 2 }y |
  981. {14: 3 } |
  982. {0:~ }|
  983. {0:~ }|
  984. {0:~ }|
  985. ## grid 3
  986. |
  987. ## grid 4
  988. {18: 1 }{15:x }|
  989. {18: 2 }{15:y }|
  990. {18: 3 }{15: }|
  991. {16:~ }|
  992. ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}}
  993. else
  994. screen:expect([[
  995. {14: 1 }^x |
  996. {14: 2 }y |
  997. {14: 3 } {18: 1 }{15:x } |
  998. {0:~ }{18: 2 }{15:y }{0: }|
  999. {0:~ }{18: 3 }{15: }{0: }|
  1000. {0:~ }{16:~ }{0: }|
  1001. |
  1002. ]])
  1003. end
  1004. local buf = meths.create_buf(false, true)
  1005. meths.win_set_buf(win, buf)
  1006. if multigrid then
  1007. screen:expect{grid=[[
  1008. ## grid 1
  1009. [2:----------------------------------------]|
  1010. [2:----------------------------------------]|
  1011. [2:----------------------------------------]|
  1012. [2:----------------------------------------]|
  1013. [2:----------------------------------------]|
  1014. [2:----------------------------------------]|
  1015. [3:----------------------------------------]|
  1016. ## grid 2
  1017. {14: 1 }^x |
  1018. {14: 2 }y |
  1019. {14: 3 } |
  1020. {0:~ }|
  1021. {0:~ }|
  1022. {0:~ }|
  1023. ## grid 3
  1024. |
  1025. ## grid 4
  1026. {18: 1 }{15: }|
  1027. {16:~ }|
  1028. {16:~ }|
  1029. {16:~ }|
  1030. ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}}
  1031. else
  1032. screen:expect([[
  1033. {14: 1 }^x |
  1034. {14: 2 }y |
  1035. {14: 3 } {18: 1 }{15: } |
  1036. {0:~ }{16:~ }{0: }|
  1037. {0:~ }{16:~ }{0: }|
  1038. {0:~ }{16:~ }{0: }|
  1039. |
  1040. ]])
  1041. end
  1042. end)
  1043. it("can use 'minimal' style", function()
  1044. command('set number')
  1045. command('set signcolumn=yes')
  1046. command('set colorcolumn=1')
  1047. command('set cursorline')
  1048. command('set foldcolumn=1')
  1049. command('hi NormalFloat guibg=#333333')
  1050. feed('ix<cr>y<cr><esc>gg')
  1051. local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
  1052. if multigrid then
  1053. screen:expect{grid=[[
  1054. ## grid 1
  1055. [2:----------------------------------------]|
  1056. [2:----------------------------------------]|
  1057. [2:----------------------------------------]|
  1058. [2:----------------------------------------]|
  1059. [2:----------------------------------------]|
  1060. [2:----------------------------------------]|
  1061. [3:----------------------------------------]|
  1062. ## grid 2
  1063. {19: }{20: 1 }{22:^x}{21: }|
  1064. {19: }{14: 2 }{22:y} |
  1065. {19: }{14: 3 }{22: } |
  1066. {0:~ }|
  1067. {0:~ }|
  1068. {0:~ }|
  1069. ## grid 3
  1070. |
  1071. ## grid 4
  1072. {15:x }|
  1073. {15:y }|
  1074. {15: }|
  1075. {15: }|
  1076. ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}}
  1077. else
  1078. screen:expect{grid=[[
  1079. {19: }{20: 1 }{22:^x}{21: }|
  1080. {19: }{14: 2 }{22:y} |
  1081. {19: }{14: 3 }{22: } {15:x } |
  1082. {0:~ }{15:y }{0: }|
  1083. {0:~ }{15: }{0: }|
  1084. {0:~ }{15: }{0: }|
  1085. |
  1086. ]]}
  1087. end
  1088. -- signcolumn=yes still works if there actually are signs
  1089. command('sign define piet1 text=𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄ texthl=Search')
  1090. command('sign place 1 line=1 name=piet1 buffer=1')
  1091. if multigrid then
  1092. screen:expect{grid=[[
  1093. ## grid 1
  1094. [2:----------------------------------------]|
  1095. [2:----------------------------------------]|
  1096. [2:----------------------------------------]|
  1097. [2:----------------------------------------]|
  1098. [2:----------------------------------------]|
  1099. [2:----------------------------------------]|
  1100. [3:----------------------------------------]|
  1101. ## grid 2
  1102. {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
  1103. {19: }{14: 2 }{22:y} |
  1104. {19: }{14: 3 }{22: } |
  1105. {0:~ }|
  1106. {0:~ }|
  1107. {0:~ }|
  1108. ## grid 3
  1109. |
  1110. ## grid 4
  1111. {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
  1112. {19: }{15:y }|
  1113. {19: }{15: }|
  1114. {15: }|
  1115. ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}}
  1116. else
  1117. screen:expect([[
  1118. {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
  1119. {19: }{14: 2 }{22:y} |
  1120. {19: }{14: 3 }{22: } {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
  1121. {0:~ }{19: }{15:y }{0: }|
  1122. {0:~ }{19: }{15: }{0: }|
  1123. {0:~ }{15: }{0: }|
  1124. |
  1125. ]])
  1126. end
  1127. command('sign unplace 1 buffer=1')
  1128. local buf = meths.create_buf(false, true)
  1129. meths.win_set_buf(win, buf)
  1130. if multigrid then
  1131. screen:expect{grid=[[
  1132. ## grid 1
  1133. [2:----------------------------------------]|
  1134. [2:----------------------------------------]|
  1135. [2:----------------------------------------]|
  1136. [2:----------------------------------------]|
  1137. [2:----------------------------------------]|
  1138. [2:----------------------------------------]|
  1139. [3:----------------------------------------]|
  1140. ## grid 2
  1141. {19: }{20: 1 }{22:^x}{21: }|
  1142. {19: }{14: 2 }{22:y} |
  1143. {19: }{14: 3 }{22: } |
  1144. {0:~ }|
  1145. {0:~ }|
  1146. {0:~ }|
  1147. ## grid 3
  1148. |
  1149. ## grid 4
  1150. {15: }|
  1151. {15: }|
  1152. {15: }|
  1153. {15: }|
  1154. ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}}
  1155. else
  1156. screen:expect([[
  1157. {19: }{20: 1 }{22:^x}{21: }|
  1158. {19: }{14: 2 }{22:y} |
  1159. {19: }{14: 3 }{22: } {15: } |
  1160. {0:~ }{15: }{0: }|
  1161. {0:~ }{15: }{0: }|
  1162. {0:~ }{15: }{0: }|
  1163. |
  1164. ]])
  1165. end
  1166. end)
  1167. it("would not break 'minimal' style with signcolumn=auto:[min]-[max]", function()
  1168. command('set number')
  1169. command('set signcolumn=auto:1-3')
  1170. command('set colorcolumn=1')
  1171. command('set cursorline')
  1172. command('set foldcolumn=1')
  1173. command('hi NormalFloat guibg=#333333')
  1174. feed('ix<cr>y<cr><esc>gg')
  1175. local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
  1176. if multigrid then
  1177. screen:expect{grid=[[
  1178. ## grid 1
  1179. [2:----------------------------------------]|
  1180. [2:----------------------------------------]|
  1181. [2:----------------------------------------]|
  1182. [2:----------------------------------------]|
  1183. [2:----------------------------------------]|
  1184. [2:----------------------------------------]|
  1185. [3:----------------------------------------]|
  1186. ## grid 2
  1187. {19: }{20: 1 }{22:^x}{21: }|
  1188. {19: }{14: 2 }{22:y} |
  1189. {19: }{14: 3 }{22: } |
  1190. {0:~ }|
  1191. {0:~ }|
  1192. {0:~ }|
  1193. ## grid 3
  1194. |
  1195. ## grid 4
  1196. {15:x }|
  1197. {15:y }|
  1198. {15: }|
  1199. {15: }|
  1200. ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}}
  1201. else
  1202. screen:expect{grid=[[
  1203. {19: }{20: 1 }{22:^x}{21: }|
  1204. {19: }{14: 2 }{22:y} |
  1205. {19: }{14: 3 }{22: } {15:x } |
  1206. {0:~ }{15:y }{0: }|
  1207. {0:~ }{15: }{0: }|
  1208. {0:~ }{15: }{0: }|
  1209. |
  1210. ]]}
  1211. end
  1212. command('sign define piet1 text=𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄ texthl=Search')
  1213. command('sign place 1 line=1 name=piet1 buffer=1')
  1214. -- signcolumn=auto:1-3 still works if there actually are signs
  1215. if multigrid then
  1216. screen:expect{grid=[[
  1217. ## grid 1
  1218. [2:----------------------------------------]|
  1219. [2:----------------------------------------]|
  1220. [2:----------------------------------------]|
  1221. [2:----------------------------------------]|
  1222. [2:----------------------------------------]|
  1223. [2:----------------------------------------]|
  1224. [3:----------------------------------------]|
  1225. ## grid 2
  1226. {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
  1227. {19: }{14: 2 }{22:y} |
  1228. {19: }{14: 3 }{22: } |
  1229. {0:~ }|
  1230. {0:~ }|
  1231. {0:~ }|
  1232. ## grid 3
  1233. |
  1234. ## grid 4
  1235. {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x }|
  1236. {19: }{15:y }|
  1237. {19: }{15: }|
  1238. {15: }|
  1239. ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}}
  1240. else
  1241. screen:expect([[
  1242. {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }|
  1243. {19: }{14: 2 }{22:y} |
  1244. {19: }{14: 3 }{22: } {17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{15:x } |
  1245. {0:~ }{19: }{15:y }{0: }|
  1246. {0:~ }{19: }{15: }{0: }|
  1247. {0:~ }{15: }{0: }|
  1248. |
  1249. ]])
  1250. end
  1251. command('sign unplace 1 buffer=1')
  1252. local buf = meths.create_buf(false, true)
  1253. meths.win_set_buf(win, buf)
  1254. if multigrid then
  1255. screen:expect{grid=[[
  1256. ## grid 1
  1257. [2:----------------------------------------]|
  1258. [2:----------------------------------------]|
  1259. [2:----------------------------------------]|
  1260. [2:----------------------------------------]|
  1261. [2:----------------------------------------]|
  1262. [2:----------------------------------------]|
  1263. [3:----------------------------------------]|
  1264. ## grid 2
  1265. {19: }{20: 1 }{22:^x}{21: }|
  1266. {19: }{14: 2 }{22:y} |
  1267. {19: }{14: 3 }{22: } |
  1268. {0:~ }|
  1269. {0:~ }|
  1270. {0:~ }|
  1271. ## grid 3
  1272. |
  1273. ## grid 4
  1274. {15: }|
  1275. {15: }|
  1276. {15: }|
  1277. {15: }|
  1278. ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}}
  1279. else
  1280. screen:expect([[
  1281. {19: }{20: 1 }{22:^x}{21: }|
  1282. {19: }{14: 2 }{22:y} |
  1283. {19: }{14: 3 }{22: } {15: } |
  1284. {0:~ }{15: }{0: }|
  1285. {0:~ }{15: }{0: }|
  1286. {0:~ }{15: }{0: }|
  1287. |
  1288. ]])
  1289. end
  1290. end)
  1291. it("would not break 'minimal' style with statuscolumn set", function()
  1292. command('set number')
  1293. command('set signcolumn=yes')
  1294. command('set colorcolumn=1')
  1295. command('set cursorline')
  1296. command('set foldcolumn=1')
  1297. command('set statuscolumn=%l%s%C')
  1298. command('hi NormalFloat guibg=#333333')
  1299. feed('ix<cr>y<cr><esc>gg')
  1300. meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'})
  1301. if multigrid then
  1302. screen:expect{grid=[[
  1303. ## grid 1
  1304. [2:----------------------------------------]|
  1305. [2:----------------------------------------]|
  1306. [2:----------------------------------------]|
  1307. [2:----------------------------------------]|
  1308. [2:----------------------------------------]|
  1309. [2:----------------------------------------]|
  1310. [3:----------------------------------------]|
  1311. ## grid 2
  1312. {20:1}{19: }{20: }{22:^x}{21: }|
  1313. {14:2}{19: }{14: }{22:y} |
  1314. {14:3}{19: }{14: }{22: } |
  1315. {0:~ }|
  1316. {0:~ }|
  1317. {0:~ }|
  1318. ## grid 3
  1319. |
  1320. ## grid 4
  1321. {15:x }|
  1322. {15:y }|
  1323. {15: }|
  1324. {15: }|
  1325. ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}}
  1326. else
  1327. screen:expect{grid=[[
  1328. {20:1}{19: }{20: }{22:^x}{21: }|
  1329. {14:2}{19: }{14: }{22:y} |
  1330. {14:3}{19: }{14: }{22: } {15:x } |
  1331. {0:~ }{15:y }{0: }|
  1332. {0:~ }{15: }{0: }|
  1333. {0:~ }{15: }{0: }|
  1334. |
  1335. ]]}
  1336. end
  1337. end)
  1338. it('can have border', function()
  1339. local buf = meths.create_buf(false, false)
  1340. meths.buf_set_lines(buf, 0, -1, true, {' halloj! ',
  1341. ' BORDAA '})
  1342. local win = meths.open_win(buf, false, {relative='editor', width=9, height=2, row=2, col=5, border="double"})
  1343. if multigrid then
  1344. screen:expect{grid=[[
  1345. ## grid 1
  1346. [2:----------------------------------------]|
  1347. [2:----------------------------------------]|
  1348. [2:----------------------------------------]|
  1349. [2:----------------------------------------]|
  1350. [2:----------------------------------------]|
  1351. [2:----------------------------------------]|
  1352. [3:----------------------------------------]|
  1353. ## grid 2
  1354. ^ |
  1355. {0:~ }|
  1356. {0:~ }|
  1357. {0:~ }|
  1358. {0:~ }|
  1359. {0:~ }|
  1360. ## grid 3
  1361. |
  1362. ## grid 5
  1363. {5:╔═════════╗}|
  1364. {5:║}{1: halloj! }{5:║}|
  1365. {5:║}{1: BORDAA }{5:║}|
  1366. {5:╚═════════╝}|
  1367. ]], float_pos={
  1368. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1369. }, win_viewport={
  1370. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1371. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1372. }}
  1373. else
  1374. screen:expect{grid=[[
  1375. ^ |
  1376. {0:~ }|
  1377. {0:~ }{5:╔═════════╗}{0: }|
  1378. {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
  1379. {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
  1380. {0:~ }{5:╚═════════╝}{0: }|
  1381. |
  1382. ]]}
  1383. end
  1384. meths.win_set_config(win, {border="single"})
  1385. if multigrid then
  1386. screen:expect{grid=[[
  1387. ## grid 1
  1388. [2:----------------------------------------]|
  1389. [2:----------------------------------------]|
  1390. [2:----------------------------------------]|
  1391. [2:----------------------------------------]|
  1392. [2:----------------------------------------]|
  1393. [2:----------------------------------------]|
  1394. [3:----------------------------------------]|
  1395. ## grid 2
  1396. ^ |
  1397. {0:~ }|
  1398. {0:~ }|
  1399. {0:~ }|
  1400. {0:~ }|
  1401. {0:~ }|
  1402. ## grid 3
  1403. |
  1404. ## grid 5
  1405. {5:┌─────────┐}|
  1406. {5:│}{1: halloj! }{5:│}|
  1407. {5:│}{1: BORDAA }{5:│}|
  1408. {5:└─────────┘}|
  1409. ]], float_pos={
  1410. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1411. }, win_viewport={
  1412. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1413. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1414. }}
  1415. else
  1416. screen:expect{grid=[[
  1417. ^ |
  1418. {0:~ }|
  1419. {0:~ }{5:┌─────────┐}{0: }|
  1420. {0:~ }{5:│}{1: halloj! }{5:│}{0: }|
  1421. {0:~ }{5:│}{1: BORDAA }{5:│}{0: }|
  1422. {0:~ }{5:└─────────┘}{0: }|
  1423. |
  1424. ]]}
  1425. end
  1426. meths.win_set_config(win, {border="rounded"})
  1427. if multigrid then
  1428. screen:expect{grid=[[
  1429. ## grid 1
  1430. [2:----------------------------------------]|
  1431. [2:----------------------------------------]|
  1432. [2:----------------------------------------]|
  1433. [2:----------------------------------------]|
  1434. [2:----------------------------------------]|
  1435. [2:----------------------------------------]|
  1436. [3:----------------------------------------]|
  1437. ## grid 2
  1438. ^ |
  1439. {0:~ }|
  1440. {0:~ }|
  1441. {0:~ }|
  1442. {0:~ }|
  1443. {0:~ }|
  1444. ## grid 3
  1445. |
  1446. ## grid 5
  1447. {5:╭─────────╮}|
  1448. {5:│}{1: halloj! }{5:│}|
  1449. {5:│}{1: BORDAA }{5:│}|
  1450. {5:╰─────────╯}|
  1451. ]], float_pos={
  1452. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1453. }, win_viewport={
  1454. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1455. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1456. }}
  1457. else
  1458. screen:expect{grid=[[
  1459. ^ |
  1460. {0:~ }|
  1461. {0:~ }{5:╭─────────╮}{0: }|
  1462. {0:~ }{5:│}{1: halloj! }{5:│}{0: }|
  1463. {0:~ }{5:│}{1: BORDAA }{5:│}{0: }|
  1464. {0:~ }{5:╰─────────╯}{0: }|
  1465. |
  1466. ]]}
  1467. end
  1468. meths.win_set_config(win, {border="solid"})
  1469. if multigrid then
  1470. screen:expect{grid=[[
  1471. ## grid 1
  1472. [2:----------------------------------------]|
  1473. [2:----------------------------------------]|
  1474. [2:----------------------------------------]|
  1475. [2:----------------------------------------]|
  1476. [2:----------------------------------------]|
  1477. [2:----------------------------------------]|
  1478. [3:----------------------------------------]|
  1479. ## grid 2
  1480. ^ |
  1481. {0:~ }|
  1482. {0:~ }|
  1483. {0:~ }|
  1484. {0:~ }|
  1485. {0:~ }|
  1486. ## grid 3
  1487. |
  1488. ## grid 5
  1489. {5: }|
  1490. {5: }{1: halloj! }{5: }|
  1491. {5: }{1: BORDAA }{5: }|
  1492. {5: }|
  1493. ]], float_pos={
  1494. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1495. }, win_viewport={
  1496. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1497. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1498. }}
  1499. else
  1500. screen:expect{grid=[[
  1501. ^ |
  1502. {0:~ }|
  1503. {0:~ }{5: }{0: }|
  1504. {0:~ }{5: }{1: halloj! }{5: }{0: }|
  1505. {0:~ }{5: }{1: BORDAA }{5: }{0: }|
  1506. {0:~ }{5: }{0: }|
  1507. |
  1508. ]]}
  1509. end
  1510. -- support: ascii char, UTF-8 char, composed char, highlight per char
  1511. meths.win_set_config(win, {border={"x", {"å", "ErrorMsg"}, {"\\"}, {"n̈̊", "Search"}}})
  1512. if multigrid then
  1513. screen:expect{grid=[[
  1514. ## grid 1
  1515. [2:----------------------------------------]|
  1516. [2:----------------------------------------]|
  1517. [2:----------------------------------------]|
  1518. [2:----------------------------------------]|
  1519. [2:----------------------------------------]|
  1520. [2:----------------------------------------]|
  1521. [3:----------------------------------------]|
  1522. ## grid 2
  1523. ^ |
  1524. {0:~ }|
  1525. {0:~ }|
  1526. {0:~ }|
  1527. {0:~ }|
  1528. {0:~ }|
  1529. ## grid 3
  1530. |
  1531. ## grid 5
  1532. {5:x}{7:ååååååååå}{5:\}|
  1533. {17:n̈̊}{1: halloj! }{17:n̈̊}|
  1534. {17:n̈̊}{1: BORDAA }{17:n̈̊}|
  1535. {5:\}{7:ååååååååå}{5:x}|
  1536. ]], float_pos={
  1537. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1538. }, win_viewport={
  1539. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1540. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1541. }}
  1542. else
  1543. screen:expect{grid=[[
  1544. ^ |
  1545. {0:~ }|
  1546. {0:~ }{5:x}{7:ååååååååå}{5:\}{0: }|
  1547. {0:~ }{17:n̈̊}{1: halloj! }{17:n̈̊}{0: }|
  1548. {0:~ }{17:n̈̊}{1: BORDAA }{17:n̈̊}{0: }|
  1549. {0:~ }{5:\}{7:ååååååååå}{5:x}{0: }|
  1550. |
  1551. ]]}
  1552. end
  1553. meths.win_set_config(win, {border="none"})
  1554. if multigrid then
  1555. screen:expect{grid=[[
  1556. ## grid 1
  1557. [2:----------------------------------------]|
  1558. [2:----------------------------------------]|
  1559. [2:----------------------------------------]|
  1560. [2:----------------------------------------]|
  1561. [2:----------------------------------------]|
  1562. [2:----------------------------------------]|
  1563. [3:----------------------------------------]|
  1564. ## grid 2
  1565. ^ |
  1566. {0:~ }|
  1567. {0:~ }|
  1568. {0:~ }|
  1569. {0:~ }|
  1570. {0:~ }|
  1571. ## grid 3
  1572. |
  1573. ## grid 5
  1574. {1: halloj! }|
  1575. {1: BORDAA }|
  1576. ]], float_pos={
  1577. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1578. }, win_viewport={
  1579. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1580. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1581. }}
  1582. else
  1583. screen:expect{grid=[[
  1584. ^ |
  1585. {0:~ }|
  1586. {0:~ }{1: halloj! }{0: }|
  1587. {0:~ }{1: BORDAA }{0: }|
  1588. {0:~ }|
  1589. {0:~ }|
  1590. |
  1591. ]]}
  1592. end
  1593. meths.win_set_config(win, {border={"", "", "", ">", "", "", "", "<"}})
  1594. if multigrid then
  1595. screen:expect{grid=[[
  1596. ## grid 1
  1597. [2:----------------------------------------]|
  1598. [2:----------------------------------------]|
  1599. [2:----------------------------------------]|
  1600. [2:----------------------------------------]|
  1601. [2:----------------------------------------]|
  1602. [2:----------------------------------------]|
  1603. [3:----------------------------------------]|
  1604. ## grid 2
  1605. ^ |
  1606. {0:~ }|
  1607. {0:~ }|
  1608. {0:~ }|
  1609. {0:~ }|
  1610. {0:~ }|
  1611. ## grid 3
  1612. |
  1613. ## grid 5
  1614. {5:<}{1: halloj! }{5:>}|
  1615. {5:<}{1: BORDAA }{5:>}|
  1616. ]], float_pos={
  1617. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1618. }, win_viewport={
  1619. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1620. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1621. }}
  1622. else
  1623. screen:expect{grid=[[
  1624. ^ |
  1625. {0:~ }|
  1626. {0:~ }{5:<}{1: halloj! }{5:>}{0: }|
  1627. {0:~ }{5:<}{1: BORDAA }{5:>}{0: }|
  1628. {0:~ }|
  1629. {0:~ }|
  1630. |
  1631. ]]}
  1632. end
  1633. meths.win_set_config(win, {border={"", "_", "", "", "", "-", "", ""}})
  1634. if multigrid then
  1635. screen:expect{grid=[[
  1636. ## grid 1
  1637. [2:----------------------------------------]|
  1638. [2:----------------------------------------]|
  1639. [2:----------------------------------------]|
  1640. [2:----------------------------------------]|
  1641. [2:----------------------------------------]|
  1642. [2:----------------------------------------]|
  1643. [3:----------------------------------------]|
  1644. ## grid 2
  1645. ^ |
  1646. {0:~ }|
  1647. {0:~ }|
  1648. {0:~ }|
  1649. {0:~ }|
  1650. {0:~ }|
  1651. ## grid 3
  1652. |
  1653. ## grid 5
  1654. {5:_________}|
  1655. {1: halloj! }|
  1656. {1: BORDAA }|
  1657. {5:---------}|
  1658. ]], float_pos={
  1659. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1660. }, win_viewport={
  1661. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1662. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1663. }}
  1664. else
  1665. screen:expect{grid=[[
  1666. ^ |
  1667. {0:~ }|
  1668. {0:~ }{5:_________}{0: }|
  1669. {0:~ }{1: halloj! }{0: }|
  1670. {0:~ }{1: BORDAA }{0: }|
  1671. {0:~ }{5:---------}{0: }|
  1672. |
  1673. ]]}
  1674. end
  1675. insert [[
  1676. neeed some dummy
  1677. background text
  1678. to show the effect
  1679. of color blending
  1680. of border shadow
  1681. ]]
  1682. meths.win_set_config(win, {border="shadow"})
  1683. if multigrid then
  1684. screen:expect{grid=[[
  1685. ## grid 1
  1686. [2:----------------------------------------]|
  1687. [2:----------------------------------------]|
  1688. [2:----------------------------------------]|
  1689. [2:----------------------------------------]|
  1690. [2:----------------------------------------]|
  1691. [2:----------------------------------------]|
  1692. [3:----------------------------------------]|
  1693. ## grid 2
  1694. neeed some dummy |
  1695. background text |
  1696. to show the effect |
  1697. of color blending |
  1698. of border shadow |
  1699. ^ |
  1700. ## grid 3
  1701. |
  1702. ## grid 5
  1703. {1: halloj! }{25: }|
  1704. {1: BORDAA }{26: }|
  1705. {25: }{26: }|
  1706. ]], float_pos={
  1707. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1708. }, win_viewport={
  1709. [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 5, curcol = 0, linecount = 6, sum_scroll_delta = 0};
  1710. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1711. }}
  1712. else
  1713. screen:expect{grid=[[
  1714. neeed some dummy |
  1715. background text |
  1716. to {1: halloj! }{23:e}ffect |
  1717. of {1: BORDAA }{24:n}ding |
  1718. of {23:b}{24:order sha}dow |
  1719. ^ |
  1720. |
  1721. ]]}
  1722. end
  1723. end)
  1724. it('validates title title_pos', function()
  1725. local buf = meths.create_buf(false,false)
  1726. eq("title requires border to be set",
  1727. pcall_err(meths.open_win,buf, false, {
  1728. relative='editor', width=9, height=2, row=2, col=5, title='Title',
  1729. }))
  1730. eq("title_pos requires title to be set",
  1731. pcall_err(meths.open_win,buf, false, {
  1732. relative='editor', width=9, height=2, row=2, col=5,
  1733. border='single', title_pos='left',
  1734. }))
  1735. end)
  1736. it('validate title_pos in nvim_win_get_config', function()
  1737. local title_pos = exec_lua([[
  1738. local bufnr = vim.api.nvim_create_buf(false, false)
  1739. local opts = {
  1740. relative = 'editor',
  1741. col = 2,
  1742. row = 5,
  1743. height = 2,
  1744. width = 9,
  1745. border = 'double',
  1746. title = 'Test',
  1747. title_pos = 'center'
  1748. }
  1749. local win_id = vim.api.nvim_open_win(bufnr, true, opts)
  1750. return vim.api.nvim_win_get_config(win_id).title_pos
  1751. ]])
  1752. eq('center', title_pos)
  1753. end)
  1754. it('border with title', function()
  1755. local buf = meths.create_buf(false, false)
  1756. meths.buf_set_lines(buf, 0, -1, true, {' halloj! ',
  1757. ' BORDAA '})
  1758. local win = meths.open_win(buf, false, {
  1759. relative='editor', width=9, height=2, row=2, col=5, border="double",
  1760. title = "Left",title_pos = "left",
  1761. })
  1762. if multigrid then
  1763. screen:expect{grid=[[
  1764. ## grid 1
  1765. [2:----------------------------------------]|
  1766. [2:----------------------------------------]|
  1767. [2:----------------------------------------]|
  1768. [2:----------------------------------------]|
  1769. [2:----------------------------------------]|
  1770. [2:----------------------------------------]|
  1771. [3:----------------------------------------]|
  1772. ## grid 2
  1773. ^ |
  1774. {0:~ }|
  1775. {0:~ }|
  1776. {0:~ }|
  1777. {0:~ }|
  1778. {0:~ }|
  1779. ## grid 3
  1780. |
  1781. ## grid 5
  1782. {5:╔}{11:Left}{5:═════╗}|
  1783. {5:║}{1: halloj! }{5:║}|
  1784. {5:║}{1: BORDAA }{5:║}|
  1785. {5:╚═════════╝}|
  1786. ]], float_pos={
  1787. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1788. }, win_viewport={
  1789. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1790. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1791. }}
  1792. else
  1793. screen:expect{grid=[[
  1794. ^ |
  1795. {0:~ }|
  1796. {0:~ }{5:╔}{11:Left}{5:═════╗}{0: }|
  1797. {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
  1798. {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
  1799. {0:~ }{5:╚═════════╝}{0: }|
  1800. |
  1801. ]]}
  1802. end
  1803. meths.win_set_config(win, {title= "Center",title_pos="center"})
  1804. if multigrid then
  1805. screen:expect{grid=[[
  1806. ## grid 1
  1807. [2:----------------------------------------]|
  1808. [2:----------------------------------------]|
  1809. [2:----------------------------------------]|
  1810. [2:----------------------------------------]|
  1811. [2:----------------------------------------]|
  1812. [2:----------------------------------------]|
  1813. [3:----------------------------------------]|
  1814. ## grid 2
  1815. ^ |
  1816. {0:~ }|
  1817. {0:~ }|
  1818. {0:~ }|
  1819. {0:~ }|
  1820. {0:~ }|
  1821. ## grid 3
  1822. |
  1823. ## grid 5
  1824. {5:╔═}{11:Center}{5:══╗}|
  1825. {5:║}{1: halloj! }{5:║}|
  1826. {5:║}{1: BORDAA }{5:║}|
  1827. {5:╚═════════╝}|
  1828. ]], float_pos={
  1829. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1830. }, win_viewport={
  1831. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1832. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1833. }}
  1834. else
  1835. screen:expect{grid=[[
  1836. ^ |
  1837. {0:~ }|
  1838. {0:~ }{5:╔═}{11:Center}{5:══╗}{0: }|
  1839. {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
  1840. {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
  1841. {0:~ }{5:╚═════════╝}{0: }|
  1842. |
  1843. ]]}
  1844. end
  1845. meths.win_set_config(win, {title= "Right",title_pos="right"})
  1846. if multigrid then
  1847. screen:expect{grid=[[
  1848. ## grid 1
  1849. [2:----------------------------------------]|
  1850. [2:----------------------------------------]|
  1851. [2:----------------------------------------]|
  1852. [2:----------------------------------------]|
  1853. [2:----------------------------------------]|
  1854. [2:----------------------------------------]|
  1855. [3:----------------------------------------]|
  1856. ## grid 2
  1857. ^ |
  1858. {0:~ }|
  1859. {0:~ }|
  1860. {0:~ }|
  1861. {0:~ }|
  1862. {0:~ }|
  1863. ## grid 3
  1864. |
  1865. ## grid 5
  1866. {5:╔════}{11:Right}{5:╗}|
  1867. {5:║}{1: halloj! }{5:║}|
  1868. {5:║}{1: BORDAA }{5:║}|
  1869. {5:╚═════════╝}|
  1870. ]], float_pos={
  1871. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1872. }, win_viewport={
  1873. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1874. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1875. }}
  1876. else
  1877. screen:expect{grid=[[
  1878. ^ |
  1879. {0:~ }|
  1880. {0:~ }{5:╔════}{11:Right}{5:╗}{0: }|
  1881. {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
  1882. {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
  1883. {0:~ }{5:╚═════════╝}{0: }|
  1884. |
  1885. ]]}
  1886. end
  1887. meths.win_set_config(win, {title= { {"🦄"},{"BB"}},title_pos="right"})
  1888. if multigrid then
  1889. screen:expect{grid=[[
  1890. ## grid 1
  1891. [2:----------------------------------------]|
  1892. [2:----------------------------------------]|
  1893. [2:----------------------------------------]|
  1894. [2:----------------------------------------]|
  1895. [2:----------------------------------------]|
  1896. [2:----------------------------------------]|
  1897. [3:----------------------------------------]|
  1898. ## grid 2
  1899. ^ |
  1900. {0:~ }|
  1901. {0:~ }|
  1902. {0:~ }|
  1903. {0:~ }|
  1904. {0:~ }|
  1905. ## grid 3
  1906. |
  1907. ## grid 5
  1908. {5:╔═════}🦄BB{5:╗}|
  1909. {5:║}{1: halloj! }{5:║}|
  1910. {5:║}{1: BORDAA }{5:║}|
  1911. {5:╚═════════╝}|
  1912. ]], float_pos={
  1913. [5] = { { id = 1002 }, "NW", 1, 2, 5, true }
  1914. }, win_viewport={
  1915. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1916. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  1917. }}
  1918. else
  1919. screen:expect{grid=[[
  1920. ^ |
  1921. {0:~ }|
  1922. {0:~ }{5:╔═════}🦄BB{5:╗}{0: }|
  1923. {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
  1924. {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
  1925. {0:~ }{5:╚═════════╝}{0: }|
  1926. |
  1927. ]]}
  1928. end
  1929. end)
  1930. it('terminates border on edge of viewport when window extends past viewport', function()
  1931. local buf = meths.create_buf(false, false)
  1932. meths.open_win(buf, false, {relative='editor', width=40, height=7, row=0, col=0, border="single", zindex=201})
  1933. if multigrid then
  1934. screen:expect{grid=[[
  1935. ## grid 1
  1936. [2:----------------------------------------]|
  1937. [2:----------------------------------------]|
  1938. [2:----------------------------------------]|
  1939. [2:----------------------------------------]|
  1940. [2:----------------------------------------]|
  1941. [2:----------------------------------------]|
  1942. [3:----------------------------------------]|
  1943. ## grid 2
  1944. ^ |
  1945. {0:~ }|
  1946. {0:~ }|
  1947. {0:~ }|
  1948. {0:~ }|
  1949. {0:~ }|
  1950. ## grid 3
  1951. |
  1952. ## grid 4
  1953. {5:┌────────────────────────────────────────┐}|
  1954. {5:│}{1: }{5:│}|
  1955. {5:│}{2:~ }{5:│}|
  1956. {5:│}{2:~ }{5:│}|
  1957. {5:│}{2:~ }{5:│}|
  1958. {5:│}{2:~ }{5:│}|
  1959. {5:│}{2:~ }{5:│}|
  1960. {5:│}{2:~ }{5:│}|
  1961. {5:└────────────────────────────────────────┘}|
  1962. ]], float_pos={
  1963. [4] = { { id = 1001 }, "NW", 1, 0, 0, true, 201 }
  1964. }, win_viewport={
  1965. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1966. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  1967. }}
  1968. else
  1969. screen:expect{grid=[[
  1970. {5:^┌──────────────────────────────────────┐}|
  1971. {5:│}{1: }{5:│}|
  1972. {5:│}{2:~ }{5:│}|
  1973. {5:│}{2:~ }{5:│}|
  1974. {5:│}{2:~ }{5:│}|
  1975. {5:│}{2:~ }{5:│}|
  1976. {5:└──────────────────────────────────────┘}|
  1977. ]]}
  1978. end
  1979. end)
  1980. it('with border show popupmenu', function()
  1981. screen:try_resize(40,10)
  1982. local buf = meths.create_buf(false, false)
  1983. meths.buf_set_lines(buf, 0, -1, true, {'aaa aab ',
  1984. 'abb acc ', ''})
  1985. meths.open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5, border="double"})
  1986. feed 'G'
  1987. if multigrid then
  1988. screen:expect{grid=[[
  1989. ## grid 1
  1990. [2:----------------------------------------]|
  1991. [2:----------------------------------------]|
  1992. [2:----------------------------------------]|
  1993. [2:----------------------------------------]|
  1994. [2:----------------------------------------]|
  1995. [2:----------------------------------------]|
  1996. [2:----------------------------------------]|
  1997. [2:----------------------------------------]|
  1998. [2:----------------------------------------]|
  1999. [3:----------------------------------------]|
  2000. ## grid 2
  2001. |
  2002. {0:~ }|
  2003. {0:~ }|
  2004. {0:~ }|
  2005. {0:~ }|
  2006. {0:~ }|
  2007. {0:~ }|
  2008. {0:~ }|
  2009. {0:~ }|
  2010. ## grid 3
  2011. |
  2012. ## grid 5
  2013. {5:╔═════════╗}|
  2014. {5:║}{1:aaa aab }{5:║}|
  2015. {5:║}{1:abb acc }{5:║}|
  2016. {5:║}{1:^ }{5:║}|
  2017. {5:╚═════════╝}|
  2018. ]], float_pos={
  2019. [5] = { { id = 1002 }, "NW", 1, 0, 5, true };
  2020. }, win_viewport={
  2021. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2022. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 0, linecount = 3, sum_scroll_delta = 0};
  2023. }}
  2024. else
  2025. screen:expect{grid=[[
  2026. {5:╔═════════╗} |
  2027. {0:~ }{5:║}{1:aaa aab }{5:║}{0: }|
  2028. {0:~ }{5:║}{1:abb acc }{5:║}{0: }|
  2029. {0:~ }{5:║}{1:^ }{5:║}{0: }|
  2030. {0:~ }{5:╚═════════╝}{0: }|
  2031. {0:~ }|
  2032. {0:~ }|
  2033. {0:~ }|
  2034. {0:~ }|
  2035. |
  2036. ]]}
  2037. end
  2038. feed 'i<c-x><c-p>'
  2039. if multigrid then
  2040. screen:expect{grid=[[
  2041. ## grid 1
  2042. [2:----------------------------------------]|
  2043. [2:----------------------------------------]|
  2044. [2:----------------------------------------]|
  2045. [2:----------------------------------------]|
  2046. [2:----------------------------------------]|
  2047. [2:----------------------------------------]|
  2048. [2:----------------------------------------]|
  2049. [2:----------------------------------------]|
  2050. [2:----------------------------------------]|
  2051. [3:----------------------------------------]|
  2052. ## grid 2
  2053. |
  2054. {0:~ }|
  2055. {0:~ }|
  2056. {0:~ }|
  2057. {0:~ }|
  2058. {0:~ }|
  2059. {0:~ }|
  2060. {0:~ }|
  2061. {0:~ }|
  2062. ## grid 3
  2063. {3:-- }{8:match 1 of 4} |
  2064. ## grid 5
  2065. {5:╔═════════╗}|
  2066. {5:║}{1:aaa aab }{5:║}|
  2067. {5:║}{1:abb acc }{5:║}|
  2068. {5:║}{1:acc^ }{5:║}|
  2069. {5:╚═════════╝}|
  2070. ## grid 6
  2071. {1: aaa }|
  2072. {1: aab }|
  2073. {1: abb }|
  2074. {13: acc }|
  2075. ]], float_pos={
  2076. [5] = { { id = 1002 }, "NW", 1, 0, 5, true, 50 };
  2077. [6] = { { id = -1 }, "NW", 5, 4, 0, false, 100 };
  2078. }, win_viewport={
  2079. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0};
  2080. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 3, linecount=3, sum_scroll_delta = 0};
  2081. }}
  2082. else
  2083. screen:expect{grid=[[
  2084. {5:╔═════════╗} |
  2085. {0:~ }{5:║}{1:aaa aab }{5:║}{0: }|
  2086. {0:~ }{5:║}{1:abb acc }{5:║}{0: }|
  2087. {0:~ }{5:║}{1:acc^ }{5:║}{0: }|
  2088. {0:~ }{1: aaa }{0: }|
  2089. {0:~ }{1: aab }{0: }|
  2090. {0:~ }{1: abb }{0: }|
  2091. {0:~ }{13: acc }{0: }|
  2092. {0:~ }|
  2093. {3:-- }{8:match 1 of 4} |
  2094. ]]}
  2095. end
  2096. feed '<esc>'
  2097. if multigrid then
  2098. screen:expect{grid=[[
  2099. ## grid 1
  2100. [2:----------------------------------------]|
  2101. [2:----------------------------------------]|
  2102. [2:----------------------------------------]|
  2103. [2:----------------------------------------]|
  2104. [2:----------------------------------------]|
  2105. [2:----------------------------------------]|
  2106. [2:----------------------------------------]|
  2107. [2:----------------------------------------]|
  2108. [2:----------------------------------------]|
  2109. [3:----------------------------------------]|
  2110. ## grid 2
  2111. |
  2112. {0:~ }|
  2113. {0:~ }|
  2114. {0:~ }|
  2115. {0:~ }|
  2116. {0:~ }|
  2117. {0:~ }|
  2118. {0:~ }|
  2119. {0:~ }|
  2120. ## grid 3
  2121. |
  2122. ## grid 5
  2123. {5:╔═════════╗}|
  2124. {5:║}{1:aaa aab }{5:║}|
  2125. {5:║}{1:abb acc }{5:║}|
  2126. {5:║}{1:ac^c }{5:║}|
  2127. {5:╚═════════╝}|
  2128. ]], float_pos={
  2129. [5] = { { id = 1002 }, "NW", 1, 0, 5, true };
  2130. }, win_viewport={
  2131. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2132. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0};
  2133. }}
  2134. else
  2135. screen:expect{grid=[[
  2136. {5:╔═════════╗} |
  2137. {0:~ }{5:║}{1:aaa aab }{5:║}{0: }|
  2138. {0:~ }{5:║}{1:abb acc }{5:║}{0: }|
  2139. {0:~ }{5:║}{1:ac^c }{5:║}{0: }|
  2140. {0:~ }{5:╚═════════╝}{0: }|
  2141. {0:~ }|
  2142. {0:~ }|
  2143. {0:~ }|
  2144. {0:~ }|
  2145. |
  2146. ]]}
  2147. end
  2148. exec([[
  2149. nnoremenu Test.foo :
  2150. nnoremenu Test.bar :
  2151. nnoremenu Test.baz :
  2152. ]])
  2153. feed ':popup Test<CR>'
  2154. if multigrid then
  2155. screen:expect{grid=[[
  2156. ## grid 1
  2157. [2:----------------------------------------]|
  2158. [2:----------------------------------------]|
  2159. [2:----------------------------------------]|
  2160. [2:----------------------------------------]|
  2161. [2:----------------------------------------]|
  2162. [2:----------------------------------------]|
  2163. [2:----------------------------------------]|
  2164. [2:----------------------------------------]|
  2165. [2:----------------------------------------]|
  2166. [3:----------------------------------------]|
  2167. ## grid 2
  2168. |
  2169. {0:~ }|
  2170. {0:~ }|
  2171. {0:~ }|
  2172. {0:~ }|
  2173. {0:~ }|
  2174. {0:~ }|
  2175. {0:~ }|
  2176. {0:~ }|
  2177. ## grid 3
  2178. :popup Test |
  2179. ## grid 5
  2180. {5:╔═════════╗}|
  2181. {5:║}{1:aaa aab }{5:║}|
  2182. {5:║}{1:abb acc }{5:║}|
  2183. {5:║}{1:ac^c }{5:║}|
  2184. {5:╚═════════╝}|
  2185. ## grid 6
  2186. {1: foo }|
  2187. {1: bar }|
  2188. {1: baz }|
  2189. ]], float_pos={
  2190. [5] = { { id = 1002 }, "NW", 1, 0, 5, true };
  2191. [6] = { { id = -1 }, "NW", 5, 4, 2, false, 250 };
  2192. }, win_viewport={
  2193. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2194. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0};
  2195. }}
  2196. else
  2197. screen:expect{grid=[[
  2198. {5:╔═════════╗} |
  2199. {0:~ }{5:║}{1:aaa aab }{5:║}{0: }|
  2200. {0:~ }{5:║}{1:abb acc }{5:║}{0: }|
  2201. {0:~ }{5:║}{1:ac^c }{5:║}{0: }|
  2202. {0:~ }{5:╚═}{1: foo }{5:═══╝}{0: }|
  2203. {0:~ }{1: bar }{0: }|
  2204. {0:~ }{1: baz }{0: }|
  2205. {0:~ }|
  2206. {0:~ }|
  2207. :popup Test |
  2208. ]]}
  2209. end
  2210. end)
  2211. it('show ruler of current floating window', function()
  2212. command 'set ruler'
  2213. local buf = meths.create_buf(false, false)
  2214. meths.buf_set_lines(buf, 0, -1, true, {'aaa aab ',
  2215. 'abb acc '})
  2216. meths.open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5})
  2217. feed 'gg'
  2218. if multigrid then
  2219. screen:expect{grid=[[
  2220. ## grid 1
  2221. [2:----------------------------------------]|
  2222. [2:----------------------------------------]|
  2223. [2:----------------------------------------]|
  2224. [2:----------------------------------------]|
  2225. [2:----------------------------------------]|
  2226. [2:----------------------------------------]|
  2227. [3:----------------------------------------]|
  2228. ## grid 2
  2229. |
  2230. {0:~ }|
  2231. {0:~ }|
  2232. {0:~ }|
  2233. {0:~ }|
  2234. {0:~ }|
  2235. ## grid 3
  2236. 1,1 All |
  2237. ## grid 5
  2238. {1:^aaa aab }|
  2239. {1:abb acc }|
  2240. {2:~ }|
  2241. ]], float_pos={
  2242. [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50};
  2243. }, win_viewport={
  2244. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2245. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  2246. }}
  2247. else
  2248. screen:expect{grid=[[
  2249. {1:^aaa aab } |
  2250. {0:~ }{1:abb acc }{0: }|
  2251. {0:~ }{2:~ }{0: }|
  2252. {0:~ }|
  2253. {0:~ }|
  2254. {0:~ }|
  2255. 1,1 All |
  2256. ]]}
  2257. end
  2258. feed 'w'
  2259. if multigrid then
  2260. screen:expect{grid=[[
  2261. ## grid 1
  2262. [2:----------------------------------------]|
  2263. [2:----------------------------------------]|
  2264. [2:----------------------------------------]|
  2265. [2:----------------------------------------]|
  2266. [2:----------------------------------------]|
  2267. [2:----------------------------------------]|
  2268. [3:----------------------------------------]|
  2269. ## grid 2
  2270. |
  2271. {0:~ }|
  2272. {0:~ }|
  2273. {0:~ }|
  2274. {0:~ }|
  2275. {0:~ }|
  2276. ## grid 3
  2277. 1,5 All |
  2278. ## grid 5
  2279. {1:aaa ^aab }|
  2280. {1:abb acc }|
  2281. {2:~ }|
  2282. ]], float_pos={
  2283. [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50};
  2284. }, win_viewport={
  2285. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2286. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 4, linecount = 2, sum_scroll_delta = 0};
  2287. }}
  2288. else
  2289. screen:expect{grid=[[
  2290. {1:aaa ^aab } |
  2291. {0:~ }{1:abb acc }{0: }|
  2292. {0:~ }{2:~ }{0: }|
  2293. {0:~ }|
  2294. {0:~ }|
  2295. {0:~ }|
  2296. 1,5 All |
  2297. ]]}
  2298. end
  2299. end)
  2300. it("correct ruler position in current float with 'rulerformat' set", function()
  2301. command 'set ruler rulerformat=fish:<><'
  2302. meths.open_win(0, true, {relative='editor', width=9, height=3, row=0, col=5})
  2303. if multigrid then
  2304. screen:expect{grid=[[
  2305. ## grid 1
  2306. [2:----------------------------------------]|
  2307. [2:----------------------------------------]|
  2308. [2:----------------------------------------]|
  2309. [2:----------------------------------------]|
  2310. [2:----------------------------------------]|
  2311. [2:----------------------------------------]|
  2312. [3:----------------------------------------]|
  2313. ## grid 2
  2314. |
  2315. {0:~ }|
  2316. {0:~ }|
  2317. {0:~ }|
  2318. {0:~ }|
  2319. {0:~ }|
  2320. ## grid 3
  2321. fish:<>< |
  2322. ## grid 4
  2323. {1:^ }|
  2324. {2:~ }|
  2325. {2:~ }|
  2326. ]], float_pos={
  2327. [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50};
  2328. }, win_viewport={
  2329. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2330. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2331. }}
  2332. else
  2333. screen:expect{grid=[[
  2334. {1:^ } |
  2335. {0:~ }{2:~ }{0: }|
  2336. {0:~ }{2:~ }{0: }|
  2337. {0:~ }|
  2338. {0:~ }|
  2339. {0:~ }|
  2340. fish:<>< |
  2341. ]]}
  2342. end
  2343. end)
  2344. it('does not show ruler of not-last current float during ins-completion', function()
  2345. screen:try_resize(50,9)
  2346. command 'set ruler showmode'
  2347. meths.open_win(0, false, {relative='editor', width=3, height=3, row=0, col=0})
  2348. meths.open_win(0, false, {relative='editor', width=3, height=3, row=0, col=5})
  2349. feed '<c-w>w'
  2350. neq('', meths.win_get_config(0).relative)
  2351. neq(funcs.winnr '$', funcs.winnr())
  2352. if multigrid then
  2353. screen:expect{grid=[[
  2354. ## grid 1
  2355. [2:--------------------------------------------------]|
  2356. [2:--------------------------------------------------]|
  2357. [2:--------------------------------------------------]|
  2358. [2:--------------------------------------------------]|
  2359. [2:--------------------------------------------------]|
  2360. [2:--------------------------------------------------]|
  2361. [2:--------------------------------------------------]|
  2362. [2:--------------------------------------------------]|
  2363. [3:--------------------------------------------------]|
  2364. ## grid 2
  2365. |
  2366. {0:~ }|
  2367. {0:~ }|
  2368. {0:~ }|
  2369. {0:~ }|
  2370. {0:~ }|
  2371. {0:~ }|
  2372. {0:~ }|
  2373. ## grid 3
  2374. 0,0-1 All |
  2375. ## grid 4
  2376. {1: }|
  2377. {2:~ }|
  2378. {2:~ }|
  2379. ## grid 5
  2380. {1:^ }|
  2381. {2:~ }|
  2382. {2:~ }|
  2383. ]], float_pos={
  2384. [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50};
  2385. [4] = {{id = 1001}, "NW", 1, 0, 0, true, 50};
  2386. }, win_viewport={
  2387. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2388. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2389. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2390. }}
  2391. else
  2392. screen:expect{grid=[[
  2393. {1: } {1:^ } |
  2394. {2:~ }{0: }{2:~ }{0: }|
  2395. {2:~ }{0: }{2:~ }{0: }|
  2396. {0:~ }|
  2397. {0:~ }|
  2398. {0:~ }|
  2399. {0:~ }|
  2400. {0:~ }|
  2401. 0,0-1 All |
  2402. ]]}
  2403. end
  2404. feed 'i<c-x>'
  2405. if multigrid then
  2406. screen:expect{grid=[[
  2407. ## grid 1
  2408. [2:--------------------------------------------------]|
  2409. [2:--------------------------------------------------]|
  2410. [2:--------------------------------------------------]|
  2411. [2:--------------------------------------------------]|
  2412. [2:--------------------------------------------------]|
  2413. [2:--------------------------------------------------]|
  2414. [2:--------------------------------------------------]|
  2415. [2:--------------------------------------------------]|
  2416. [3:--------------------------------------------------]|
  2417. ## grid 2
  2418. |
  2419. {0:~ }|
  2420. {0:~ }|
  2421. {0:~ }|
  2422. {0:~ }|
  2423. {0:~ }|
  2424. {0:~ }|
  2425. {0:~ }|
  2426. ## grid 3
  2427. {3:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} |
  2428. ## grid 4
  2429. {1: }|
  2430. {2:~ }|
  2431. {2:~ }|
  2432. ## grid 5
  2433. {1:^ }|
  2434. {2:~ }|
  2435. {2:~ }|
  2436. ]], float_pos={
  2437. [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50};
  2438. [4] = {{id = 1001}, "NW", 1, 0, 0, true, 50};
  2439. }, win_viewport={
  2440. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2441. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2442. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2443. }}
  2444. else
  2445. screen:expect{grid=[[
  2446. {1: } {1:^ } |
  2447. {2:~ }{0: }{2:~ }{0: }|
  2448. {2:~ }{0: }{2:~ }{0: }|
  2449. {0:~ }|
  2450. {0:~ }|
  2451. {0:~ }|
  2452. {0:~ }|
  2453. {0:~ }|
  2454. {3:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} |
  2455. ]]}
  2456. end
  2457. end)
  2458. it('can have minimum size', function()
  2459. insert("the background text")
  2460. local buf = meths.create_buf(false, true)
  2461. meths.buf_set_lines(buf, 0, -1, true, {'x'})
  2462. local win = meths.open_win(buf, false, {relative='win', width=1, height=1, row=0, col=4, focusable=false})
  2463. if multigrid then
  2464. screen:expect{grid=[[
  2465. ## grid 1
  2466. [2:----------------------------------------]|
  2467. [2:----------------------------------------]|
  2468. [2:----------------------------------------]|
  2469. [2:----------------------------------------]|
  2470. [2:----------------------------------------]|
  2471. [2:----------------------------------------]|
  2472. [3:----------------------------------------]|
  2473. ## grid 2
  2474. the background tex^t |
  2475. {0:~ }|
  2476. {0:~ }|
  2477. {0:~ }|
  2478. {0:~ }|
  2479. {0:~ }|
  2480. ## grid 3
  2481. |
  2482. ## grid 5
  2483. {1:x}|
  2484. ]], float_pos={
  2485. [5] = {{id = 1002}, "NW", 2, 0, 4, false}
  2486. }}
  2487. else
  2488. screen:expect([[
  2489. the {1:x}ackground tex^t |
  2490. {0:~ }|
  2491. {0:~ }|
  2492. {0:~ }|
  2493. {0:~ }|
  2494. {0:~ }|
  2495. |
  2496. ]])
  2497. end
  2498. meths.win_set_config(win, {relative='win', row=0, col=15})
  2499. if multigrid then
  2500. screen:expect{grid=[[
  2501. ## grid 1
  2502. [2:----------------------------------------]|
  2503. [2:----------------------------------------]|
  2504. [2:----------------------------------------]|
  2505. [2:----------------------------------------]|
  2506. [2:----------------------------------------]|
  2507. [2:----------------------------------------]|
  2508. [3:----------------------------------------]|
  2509. ## grid 2
  2510. the background tex^t |
  2511. {0:~ }|
  2512. {0:~ }|
  2513. {0:~ }|
  2514. {0:~ }|
  2515. {0:~ }|
  2516. ## grid 3
  2517. |
  2518. ## grid 5
  2519. {1:x}|
  2520. ]], float_pos={
  2521. [5] = {{id = 1002}, "NW", 2, 0, 15, false}
  2522. }}
  2523. else
  2524. screen:expect([[
  2525. the background {1:x}ex^t |
  2526. {0:~ }|
  2527. {0:~ }|
  2528. {0:~ }|
  2529. {0:~ }|
  2530. {0:~ }|
  2531. |
  2532. ]])
  2533. end
  2534. meths.win_close(win,false)
  2535. if multigrid then
  2536. screen:expect([[
  2537. ## grid 1
  2538. [2:----------------------------------------]|
  2539. [2:----------------------------------------]|
  2540. [2:----------------------------------------]|
  2541. [2:----------------------------------------]|
  2542. [2:----------------------------------------]|
  2543. [2:----------------------------------------]|
  2544. [3:----------------------------------------]|
  2545. ## grid 2
  2546. the background tex^t |
  2547. {0:~ }|
  2548. {0:~ }|
  2549. {0:~ }|
  2550. {0:~ }|
  2551. {0:~ }|
  2552. ## grid 3
  2553. |
  2554. ]])
  2555. else
  2556. screen:expect([[
  2557. the background tex^t |
  2558. {0:~ }|
  2559. {0:~ }|
  2560. {0:~ }|
  2561. {0:~ }|
  2562. {0:~ }|
  2563. |
  2564. ]])
  2565. end
  2566. end)
  2567. describe('no crash when rearranging windows', function()
  2568. local function test_rearrange_windows(cmd)
  2569. command('set laststatus=2')
  2570. screen:try_resize(40, 13)
  2571. command('args X1 X2 X3 X4 X5 X6')
  2572. command('sargument 2')
  2573. command('sargument 3')
  2574. local w3 = curwin()
  2575. command('sargument 4')
  2576. local w4 = curwin()
  2577. command('sargument 5')
  2578. command('sargument 6')
  2579. local float_opts = { relative = 'editor', row = 6, col = 0, width = 40, height = 1 }
  2580. meths.win_set_config(w3, float_opts)
  2581. meths.win_set_config(w4, float_opts)
  2582. command('wincmd =')
  2583. if multigrid then
  2584. screen:expect{grid=[[
  2585. ## grid 1
  2586. [8:----------------------------------------]|
  2587. [8:----------------------------------------]|
  2588. {4:X6 }|
  2589. [7:----------------------------------------]|
  2590. [7:----------------------------------------]|
  2591. {5:X5 }|
  2592. [4:----------------------------------------]|
  2593. [4:----------------------------------------]|
  2594. {5:X2 }|
  2595. [2:----------------------------------------]|
  2596. [2:----------------------------------------]|
  2597. {5:X1 }|
  2598. [3:----------------------------------------]|
  2599. ## grid 2
  2600. |
  2601. {0:~ }|
  2602. ## grid 3
  2603. |
  2604. ## grid 4
  2605. |
  2606. {0:~ }|
  2607. ## grid 5
  2608. {1: }|
  2609. ## grid 6
  2610. {1: }|
  2611. ## grid 7
  2612. |
  2613. {0:~ }|
  2614. ## grid 8
  2615. ^ |
  2616. {0:~ }|
  2617. ]], float_pos={
  2618. [5] = {{id = 1002}, "NW", 1, 6, 0, true, 50};
  2619. [6] = {{id = 1003}, "NW", 1, 6, 0, true, 50};
  2620. }, win_viewport={
  2621. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2622. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2623. [5] = {win = {id = 1002}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2624. [6] = {win = {id = 1003}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2625. [7] = {win = {id = 1004}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2626. [8] = {win = {id = 1005}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2627. }}
  2628. else
  2629. screen:expect{grid=[[
  2630. ^ |
  2631. {0:~ }|
  2632. {4:X6 }|
  2633. |
  2634. {0:~ }|
  2635. {5:X5 }|
  2636. {1: }|
  2637. {0:~ }|
  2638. {5:X2 }|
  2639. |
  2640. {0:~ }|
  2641. {5:X1 }|
  2642. |
  2643. ]]}
  2644. end
  2645. command(cmd)
  2646. if multigrid then
  2647. screen:expect{grid=[[
  2648. ## grid 1
  2649. [2:----------------------------------------]|
  2650. {4:X1 }|
  2651. [4:----------------------------------------]|
  2652. {5:X2 }|
  2653. [9:----------------------------------------]|
  2654. {5:X3 }|
  2655. [10:----------------------------------------]|
  2656. {5:X4 }|
  2657. [7:----------------------------------------]|
  2658. {5:X5 }|
  2659. [8:----------------------------------------]|
  2660. {5:X6 }|
  2661. [3:----------------------------------------]|
  2662. ## grid 2
  2663. ^ |
  2664. ## grid 3
  2665. |
  2666. ## grid 4
  2667. |
  2668. ## grid 7
  2669. |
  2670. ## grid 8
  2671. |
  2672. ## grid 9
  2673. |
  2674. ## grid 10
  2675. |
  2676. ]], win_viewport={
  2677. [2] = {win = {id = 1000}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2678. [4] = {win = {id = 1001}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2679. [7] = {win = {id = 1004}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2680. [8] = {win = {id = 1005}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2681. [9] = {win = {id = 1006}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2682. [10] = {win = {id = 1007}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  2683. }}
  2684. else
  2685. screen:expect{grid=[[
  2686. ^ |
  2687. {4:X1 }|
  2688. |
  2689. {5:X2 }|
  2690. |
  2691. {5:X3 }|
  2692. |
  2693. {5:X4 }|
  2694. |
  2695. {5:X5 }|
  2696. |
  2697. {5:X6 }|
  2698. |
  2699. ]]}
  2700. end
  2701. end
  2702. it('using :unhide', function()
  2703. test_rearrange_windows('unhide')
  2704. end)
  2705. it('using :all', function()
  2706. test_rearrange_windows('all')
  2707. end)
  2708. end)
  2709. it('API has proper error messages', function()
  2710. local buf = meths.create_buf(false,false)
  2711. eq("Invalid key: 'bork'",
  2712. pcall_err(meths.open_win,buf, false, {width=20,height=2,bork=true}))
  2713. eq("'win' key is only valid with relative='win'",
  2714. pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0}))
  2715. eq("Only one of 'relative' and 'external' must be used",
  2716. pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true}))
  2717. eq("Invalid value of 'relative' key",
  2718. pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='shell',row=0,col=0}))
  2719. eq("Invalid value of 'anchor' key",
  2720. pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'}))
  2721. eq("'relative' requires 'row'/'col' or 'bufpos'",
  2722. pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor'}))
  2723. eq("'width' key must be a positive Integer",
  2724. pcall_err(meths.open_win,buf, false, {width=-1,height=2,relative='editor', row=0, col=0}))
  2725. eq("'height' key must be a positive Integer",
  2726. pcall_err(meths.open_win,buf, false, {width=20,height=-1,relative='editor', row=0, col=0}))
  2727. eq("'height' key must be a positive Integer",
  2728. pcall_err(meths.open_win,buf, false, {width=20,height=0,relative='editor', row=0, col=0}))
  2729. eq("Must specify 'width'",
  2730. pcall_err(meths.open_win,buf, false, {relative='editor', row=0, col=0}))
  2731. eq("Must specify 'height'",
  2732. pcall_err(meths.open_win,buf, false, {relative='editor', row=0, col=0, width=2}))
  2733. end)
  2734. it('can be placed relative window or cursor', function()
  2735. screen:try_resize(40,9)
  2736. meths.buf_set_lines(0, 0, -1, true, {'just some', 'example text'})
  2737. feed('gge')
  2738. local oldwin = meths.get_current_win()
  2739. command('below split')
  2740. if multigrid then
  2741. screen:expect([[
  2742. ## grid 1
  2743. [2:----------------------------------------]|
  2744. [2:----------------------------------------]|
  2745. [2:----------------------------------------]|
  2746. {5:[No Name] [+] }|
  2747. [4:----------------------------------------]|
  2748. [4:----------------------------------------]|
  2749. [4:----------------------------------------]|
  2750. {4:[No Name] [+] }|
  2751. [3:----------------------------------------]|
  2752. ## grid 2
  2753. just some |
  2754. example text |
  2755. {0:~ }|
  2756. ## grid 3
  2757. |
  2758. ## grid 4
  2759. jus^t some |
  2760. example text |
  2761. {0:~ }|
  2762. ]])
  2763. else
  2764. screen:expect([[
  2765. just some |
  2766. example text |
  2767. {0:~ }|
  2768. {5:[No Name] [+] }|
  2769. jus^t some |
  2770. example text |
  2771. {0:~ }|
  2772. {4:[No Name] [+] }|
  2773. |
  2774. ]])
  2775. end
  2776. local buf = meths.create_buf(false,false)
  2777. -- no 'win' arg, relative default window
  2778. local win = meths.open_win(buf, false, {relative='win', width=20, height=2, row=0, col=10})
  2779. if multigrid then
  2780. screen:expect{grid=[[
  2781. ## grid 1
  2782. [2:----------------------------------------]|
  2783. [2:----------------------------------------]|
  2784. [2:----------------------------------------]|
  2785. {5:[No Name] [+] }|
  2786. [4:----------------------------------------]|
  2787. [4:----------------------------------------]|
  2788. [4:----------------------------------------]|
  2789. {4:[No Name] [+] }|
  2790. [3:----------------------------------------]|
  2791. ## grid 2
  2792. just some |
  2793. example text |
  2794. {0:~ }|
  2795. ## grid 3
  2796. |
  2797. ## grid 4
  2798. jus^t some |
  2799. example text |
  2800. {0:~ }|
  2801. ## grid 5
  2802. {1: }|
  2803. {2:~ }|
  2804. ]], float_pos={
  2805. [5] = {{id = 1002}, "NW", 4, 0, 10, true}
  2806. }}
  2807. else
  2808. screen:expect([[
  2809. just some |
  2810. example text |
  2811. {0:~ }|
  2812. {5:[No Name] [+] }|
  2813. jus^t some {1: } |
  2814. example te{2:~ } |
  2815. {0:~ }|
  2816. {4:[No Name] [+] }|
  2817. |
  2818. ]])
  2819. end
  2820. meths.win_set_config(win, {relative='cursor', row=1, col=-2})
  2821. if multigrid then
  2822. screen:expect{grid=[[
  2823. ## grid 1
  2824. [2:----------------------------------------]|
  2825. [2:----------------------------------------]|
  2826. [2:----------------------------------------]|
  2827. {5:[No Name] [+] }|
  2828. [4:----------------------------------------]|
  2829. [4:----------------------------------------]|
  2830. [4:----------------------------------------]|
  2831. {4:[No Name] [+] }|
  2832. [3:----------------------------------------]|
  2833. ## grid 2
  2834. just some |
  2835. example text |
  2836. {0:~ }|
  2837. ## grid 3
  2838. |
  2839. ## grid 4
  2840. jus^t some |
  2841. example text |
  2842. {0:~ }|
  2843. ## grid 5
  2844. {1: }|
  2845. {2:~ }|
  2846. ]], float_pos={
  2847. [5] = {{id = 1002}, "NW", 4, 1, 1, true}
  2848. }}
  2849. else
  2850. screen:expect([[
  2851. just some |
  2852. example text |
  2853. {0:~ }|
  2854. {5:[No Name] [+] }|
  2855. jus^t some |
  2856. e{1: } |
  2857. {0:~}{2:~ }{0: }|
  2858. {4:[No Name] [+] }|
  2859. |
  2860. ]])
  2861. end
  2862. meths.win_set_config(win, {relative='cursor', row=0, col=0, anchor='SW'})
  2863. if multigrid then
  2864. screen:expect{grid=[[
  2865. ## grid 1
  2866. [2:----------------------------------------]|
  2867. [2:----------------------------------------]|
  2868. [2:----------------------------------------]|
  2869. {5:[No Name] [+] }|
  2870. [4:----------------------------------------]|
  2871. [4:----------------------------------------]|
  2872. [4:----------------------------------------]|
  2873. {4:[No Name] [+] }|
  2874. [3:----------------------------------------]|
  2875. ## grid 2
  2876. just some |
  2877. example text |
  2878. {0:~ }|
  2879. ## grid 3
  2880. |
  2881. ## grid 4
  2882. jus^t some |
  2883. example text |
  2884. {0:~ }|
  2885. ## grid 5
  2886. {1: }|
  2887. {2:~ }|
  2888. ]], float_pos={
  2889. [5] = {{id = 1002}, "SW", 4, 0, 3, true}
  2890. }}
  2891. else
  2892. screen:expect([[
  2893. just some |
  2894. example text |
  2895. {0:~ }{1: }{0: }|
  2896. {5:[No}{2:~ }{5: }|
  2897. jus^t some |
  2898. example text |
  2899. {0:~ }|
  2900. {4:[No Name] [+] }|
  2901. |
  2902. ]])
  2903. end
  2904. meths.win_set_config(win, {relative='win', win=oldwin, row=1, col=10, anchor='NW'})
  2905. if multigrid then
  2906. screen:expect{grid=[[
  2907. ## grid 1
  2908. [2:----------------------------------------]|
  2909. [2:----------------------------------------]|
  2910. [2:----------------------------------------]|
  2911. {5:[No Name] [+] }|
  2912. [4:----------------------------------------]|
  2913. [4:----------------------------------------]|
  2914. [4:----------------------------------------]|
  2915. {4:[No Name] [+] }|
  2916. [3:----------------------------------------]|
  2917. ## grid 2
  2918. just some |
  2919. example text |
  2920. {0:~ }|
  2921. ## grid 3
  2922. |
  2923. ## grid 4
  2924. jus^t some |
  2925. example text |
  2926. {0:~ }|
  2927. ## grid 5
  2928. {1: }|
  2929. {2:~ }|
  2930. ]], float_pos={
  2931. [5] = {{id = 1002}, "NW", 2, 1, 10, true}
  2932. }}
  2933. else
  2934. screen:expect([[
  2935. just some |
  2936. example te{1: } |
  2937. {0:~ }{2:~ }{0: }|
  2938. {5:[No Name] [+] }|
  2939. jus^t some |
  2940. example text |
  2941. {0:~ }|
  2942. {4:[No Name] [+] }|
  2943. |
  2944. ]])
  2945. end
  2946. meths.win_set_config(win, {relative='win', win=oldwin, row=3, col=39, anchor='SE'})
  2947. if multigrid then
  2948. screen:expect{grid=[[
  2949. ## grid 1
  2950. [2:----------------------------------------]|
  2951. [2:----------------------------------------]|
  2952. [2:----------------------------------------]|
  2953. {5:[No Name] [+] }|
  2954. [4:----------------------------------------]|
  2955. [4:----------------------------------------]|
  2956. [4:----------------------------------------]|
  2957. {4:[No Name] [+] }|
  2958. [3:----------------------------------------]|
  2959. ## grid 2
  2960. just some |
  2961. example text |
  2962. {0:~ }|
  2963. ## grid 3
  2964. |
  2965. ## grid 4
  2966. jus^t some |
  2967. example text |
  2968. {0:~ }|
  2969. ## grid 5
  2970. {1: }|
  2971. {2:~ }|
  2972. ]], float_pos={
  2973. [5] = {{id = 1002}, "SE", 2, 3, 39, true}
  2974. }}
  2975. else
  2976. screen:expect([[
  2977. just some |
  2978. example text {1: } |
  2979. {0:~ }{2:~ }{0: }|
  2980. {5:[No Name] [+] }|
  2981. jus^t some |
  2982. example text |
  2983. {0:~ }|
  2984. {4:[No Name] [+] }|
  2985. |
  2986. ]])
  2987. end
  2988. meths.win_set_config(win, {relative='win', win=0, row=0, col=50, anchor='NE'})
  2989. if multigrid then
  2990. screen:expect{grid=[[
  2991. ## grid 1
  2992. [2:----------------------------------------]|
  2993. [2:----------------------------------------]|
  2994. [2:----------------------------------------]|
  2995. {5:[No Name] [+] }|
  2996. [4:----------------------------------------]|
  2997. [4:----------------------------------------]|
  2998. [4:----------------------------------------]|
  2999. {4:[No Name] [+] }|
  3000. [3:----------------------------------------]|
  3001. ## grid 2
  3002. just some |
  3003. example text |
  3004. {0:~ }|
  3005. ## grid 3
  3006. |
  3007. ## grid 4
  3008. jus^t some |
  3009. example text |
  3010. {0:~ }|
  3011. ## grid 5
  3012. {1: }|
  3013. {2:~ }|
  3014. ]], float_pos={
  3015. [5] = {{id = 1002}, "NE", 4, 0, 50, true}
  3016. }, win_viewport = {
  3017. [2] = {
  3018. topline = 0,
  3019. botline = 3,
  3020. curline = 0,
  3021. curcol = 3,
  3022. linecount = 2,
  3023. sum_scroll_delta = 0,
  3024. win = { id = 1000 },
  3025. },
  3026. [4] = {
  3027. topline = 0,
  3028. botline = 3,
  3029. curline = 0,
  3030. curcol = 3,
  3031. linecount = 2,
  3032. sum_scroll_delta = 0,
  3033. win = { id = 1001 }
  3034. },
  3035. [5] = {
  3036. topline = 0,
  3037. botline = 2,
  3038. curline = 0,
  3039. curcol = 0,
  3040. linecount = 1,
  3041. sum_scroll_delta = 0,
  3042. win = { id = 1002 }
  3043. }
  3044. }}
  3045. else
  3046. screen:expect([[
  3047. just some |
  3048. example text |
  3049. {0:~ }|
  3050. {5:[No Name] [+] }|
  3051. jus^t some {1: }|
  3052. example text {2:~ }|
  3053. {0:~ }|
  3054. {4:[No Name] [+] }|
  3055. |
  3056. ]])
  3057. end
  3058. end)
  3059. it('always anchor to corner including border', function()
  3060. screen:try_resize(40,13)
  3061. meths.buf_set_lines(0, 0, -1, true, {'just some example text', 'some more example text'})
  3062. feed('ggeee')
  3063. command('below split')
  3064. if multigrid then
  3065. screen:expect([[
  3066. ## grid 1
  3067. [2:----------------------------------------]|
  3068. [2:----------------------------------------]|
  3069. [2:----------------------------------------]|
  3070. [2:----------------------------------------]|
  3071. [2:----------------------------------------]|
  3072. {5:[No Name] [+] }|
  3073. [4:----------------------------------------]|
  3074. [4:----------------------------------------]|
  3075. [4:----------------------------------------]|
  3076. [4:----------------------------------------]|
  3077. [4:----------------------------------------]|
  3078. {4:[No Name] [+] }|
  3079. [3:----------------------------------------]|
  3080. ## grid 2
  3081. just some example text |
  3082. some more example text |
  3083. {0:~ }|
  3084. {0:~ }|
  3085. {0:~ }|
  3086. ## grid 3
  3087. |
  3088. ## grid 4
  3089. just some exampl^e text |
  3090. some more example text |
  3091. {0:~ }|
  3092. {0:~ }|
  3093. {0:~ }|
  3094. ]])
  3095. else
  3096. screen:expect([[
  3097. just some example text |
  3098. some more example text |
  3099. {0:~ }|
  3100. {0:~ }|
  3101. {0:~ }|
  3102. {5:[No Name] [+] }|
  3103. just some exampl^e text |
  3104. some more example text |
  3105. {0:~ }|
  3106. {0:~ }|
  3107. {0:~ }|
  3108. {4:[No Name] [+] }|
  3109. |
  3110. ]])
  3111. end
  3112. local buf = meths.create_buf(false, false)
  3113. meths.buf_set_lines(buf, 0, -1, true, {' halloj! ',
  3114. ' BORDAA '})
  3115. local win = meths.open_win(buf, false, {relative='cursor', width=9, height=2, row=1, col=-2, border="double"})
  3116. if multigrid then
  3117. screen:expect{grid=[[
  3118. ## grid 1
  3119. [2:----------------------------------------]|
  3120. [2:----------------------------------------]|
  3121. [2:----------------------------------------]|
  3122. [2:----------------------------------------]|
  3123. [2:----------------------------------------]|
  3124. {5:[No Name] [+] }|
  3125. [4:----------------------------------------]|
  3126. [4:----------------------------------------]|
  3127. [4:----------------------------------------]|
  3128. [4:----------------------------------------]|
  3129. [4:----------------------------------------]|
  3130. {4:[No Name] [+] }|
  3131. [3:----------------------------------------]|
  3132. ## grid 2
  3133. just some example text |
  3134. some more example text |
  3135. {0:~ }|
  3136. {0:~ }|
  3137. {0:~ }|
  3138. ## grid 3
  3139. |
  3140. ## grid 4
  3141. just some exampl^e text |
  3142. some more example text |
  3143. {0:~ }|
  3144. {0:~ }|
  3145. {0:~ }|
  3146. ## grid 6
  3147. {5:╔═════════╗}|
  3148. {5:║}{1: halloj! }{5:║}|
  3149. {5:║}{1: BORDAA }{5:║}|
  3150. {5:╚═════════╝}|
  3151. ]], float_pos={
  3152. [6] = {{id = 1003}, "NW", 4, 1, 14, true}
  3153. }}
  3154. else
  3155. screen:expect([[
  3156. just some example text |
  3157. some more example text |
  3158. {0:~ }|
  3159. {0:~ }|
  3160. {0:~ }|
  3161. {5:[No Name] [+] }|
  3162. just some exampl^e text |
  3163. some more exam{5:╔═════════╗} |
  3164. {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
  3165. {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
  3166. {0:~ }{5:╚═════════╝}{0: }|
  3167. {4:[No Name] [+] }|
  3168. |
  3169. ]])
  3170. end
  3171. meths.win_set_config(win, {relative='cursor', row=0, col=-2, anchor='NE'})
  3172. if multigrid then
  3173. screen:expect{grid=[[
  3174. ## grid 1
  3175. [2:----------------------------------------]|
  3176. [2:----------------------------------------]|
  3177. [2:----------------------------------------]|
  3178. [2:----------------------------------------]|
  3179. [2:----------------------------------------]|
  3180. {5:[No Name] [+] }|
  3181. [4:----------------------------------------]|
  3182. [4:----------------------------------------]|
  3183. [4:----------------------------------------]|
  3184. [4:----------------------------------------]|
  3185. [4:----------------------------------------]|
  3186. {4:[No Name] [+] }|
  3187. [3:----------------------------------------]|
  3188. ## grid 2
  3189. just some example text |
  3190. some more example text |
  3191. {0:~ }|
  3192. {0:~ }|
  3193. {0:~ }|
  3194. ## grid 3
  3195. |
  3196. ## grid 4
  3197. just some exampl^e text |
  3198. some more example text |
  3199. {0:~ }|
  3200. {0:~ }|
  3201. {0:~ }|
  3202. ## grid 6
  3203. {5:╔═════════╗}|
  3204. {5:║}{1: halloj! }{5:║}|
  3205. {5:║}{1: BORDAA }{5:║}|
  3206. {5:╚═════════╝}|
  3207. ]], float_pos={
  3208. [6] = {{id = 1003}, "NE", 4, 0, 14, true}
  3209. }}
  3210. else
  3211. screen:expect([[
  3212. just some example text |
  3213. some more example text |
  3214. {0:~ }|
  3215. {0:~ }|
  3216. {0:~ }|
  3217. {5:[No Name] [+] }|
  3218. jus{5:╔═════════╗}pl^e text |
  3219. som{5:║}{1: halloj! }{5:║}ple text |
  3220. {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
  3221. {0:~ }{5:╚═════════╝}{0: }|
  3222. {0:~ }|
  3223. {4:[No Name] [+] }|
  3224. |
  3225. ]])
  3226. end
  3227. meths.win_set_config(win, {relative='cursor', row=1, col=-2, anchor='SE'})
  3228. if multigrid then
  3229. screen:expect{grid=[[
  3230. ## grid 1
  3231. [2:----------------------------------------]|
  3232. [2:----------------------------------------]|
  3233. [2:----------------------------------------]|
  3234. [2:----------------------------------------]|
  3235. [2:----------------------------------------]|
  3236. {5:[No Name] [+] }|
  3237. [4:----------------------------------------]|
  3238. [4:----------------------------------------]|
  3239. [4:----------------------------------------]|
  3240. [4:----------------------------------------]|
  3241. [4:----------------------------------------]|
  3242. {4:[No Name] [+] }|
  3243. [3:----------------------------------------]|
  3244. ## grid 2
  3245. just some example text |
  3246. some more example text |
  3247. {0:~ }|
  3248. {0:~ }|
  3249. {0:~ }|
  3250. ## grid 3
  3251. |
  3252. ## grid 4
  3253. just some exampl^e text |
  3254. some more example text |
  3255. {0:~ }|
  3256. {0:~ }|
  3257. {0:~ }|
  3258. ## grid 6
  3259. {5:╔═════════╗}|
  3260. {5:║}{1: halloj! }{5:║}|
  3261. {5:║}{1: BORDAA }{5:║}|
  3262. {5:╚═════════╝}|
  3263. ]], float_pos={
  3264. [6] = {{id = 1003}, "SE", 4, 1, 14, true}
  3265. }}
  3266. else
  3267. screen:expect([[
  3268. just some example text |
  3269. some more example text |
  3270. {0:~ }|
  3271. {0:~ }{5:╔═════════╗}{0: }|
  3272. {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
  3273. {5:[No║}{1: BORDAA }{5:║ }|
  3274. jus{5:╚═════════╝}pl^e text |
  3275. some more example text |
  3276. {0:~ }|
  3277. {0:~ }|
  3278. {0:~ }|
  3279. {4:[No Name] [+] }|
  3280. |
  3281. ]])
  3282. end
  3283. meths.win_set_config(win, {relative='cursor', row=0, col=-2, anchor='SW'})
  3284. if multigrid then
  3285. screen:expect{grid=[[
  3286. ## grid 1
  3287. [2:----------------------------------------]|
  3288. [2:----------------------------------------]|
  3289. [2:----------------------------------------]|
  3290. [2:----------------------------------------]|
  3291. [2:----------------------------------------]|
  3292. {5:[No Name] [+] }|
  3293. [4:----------------------------------------]|
  3294. [4:----------------------------------------]|
  3295. [4:----------------------------------------]|
  3296. [4:----------------------------------------]|
  3297. [4:----------------------------------------]|
  3298. {4:[No Name] [+] }|
  3299. [3:----------------------------------------]|
  3300. ## grid 2
  3301. just some example text |
  3302. some more example text |
  3303. {0:~ }|
  3304. {0:~ }|
  3305. {0:~ }|
  3306. ## grid 3
  3307. |
  3308. ## grid 4
  3309. just some exampl^e text |
  3310. some more example text |
  3311. {0:~ }|
  3312. {0:~ }|
  3313. {0:~ }|
  3314. ## grid 6
  3315. {5:╔═════════╗}|
  3316. {5:║}{1: halloj! }{5:║}|
  3317. {5:║}{1: BORDAA }{5:║}|
  3318. {5:╚═════════╝}|
  3319. ]], float_pos={
  3320. [6] = {{id = 1003}, "SW", 4, 0, 14, true}
  3321. }}
  3322. else
  3323. screen:expect([[
  3324. just some example text |
  3325. some more example text |
  3326. {0:~ }{5:╔═════════╗}{0: }|
  3327. {0:~ }{5:║}{1: halloj! }{5:║}{0: }|
  3328. {0:~ }{5:║}{1: BORDAA }{5:║}{0: }|
  3329. {5:[No Name] [+] ╚═════════╝ }|
  3330. just some exampl^e text |
  3331. some more example text |
  3332. {0:~ }|
  3333. {0:~ }|
  3334. {0:~ }|
  3335. {4:[No Name] [+] }|
  3336. |
  3337. ]])
  3338. end
  3339. end)
  3340. it('anchored to another floating window updated in the same call #14735', function()
  3341. feed('i<CR><CR><CR><Esc>')
  3342. exec([[
  3343. let b1 = nvim_create_buf(v:true, v:false)
  3344. let b2 = nvim_create_buf(v:true, v:false)
  3345. let b3 = nvim_create_buf(v:true, v:false)
  3346. let b4 = nvim_create_buf(v:true, v:false)
  3347. let b5 = nvim_create_buf(v:true, v:false)
  3348. let b6 = nvim_create_buf(v:true, v:false)
  3349. let b7 = nvim_create_buf(v:true, v:false)
  3350. let b8 = nvim_create_buf(v:true, v:false)
  3351. call setbufline(b1, 1, '1')
  3352. call setbufline(b2, 1, '2')
  3353. call setbufline(b3, 1, '3')
  3354. call setbufline(b4, 1, '4')
  3355. call setbufline(b5, 1, '5')
  3356. call setbufline(b6, 1, '6')
  3357. call setbufline(b7, 1, '7')
  3358. call setbufline(b8, 1, '8')
  3359. let o1 = #{relative: 'editor', row: 1, col: 10, width: 5, height: 1}
  3360. let w1 = nvim_open_win(b1, v:false, o1)
  3361. let o2 = extendnew(o1, #{col: 30})
  3362. let w2 = nvim_open_win(b2, v:false, o2)
  3363. let o3 = extendnew(o1, #{relative: 'win', win: w1, anchor: 'NE', col: 0})
  3364. let w3 = nvim_open_win(b3, v:false, o3)
  3365. let o4 = extendnew(o3, #{win: w2})
  3366. let w4 = nvim_open_win(b4, v:false, o4)
  3367. let o5 = extendnew(o3, #{win: w3, anchor: 'SE', row: 0})
  3368. let w5 = nvim_open_win(b5, v:false, o5)
  3369. let o6 = extendnew(o5, #{win: w4})
  3370. let w6 = nvim_open_win(b6, v:false, o6)
  3371. let o7 = extendnew(o5, #{win: w5, anchor: 'SW', col: 5})
  3372. let w7 = nvim_open_win(b7, v:false, o7)
  3373. let o8 = extendnew(o7, #{win: w6})
  3374. let w8 = nvim_open_win(b8, v:false, o8)
  3375. ]])
  3376. if multigrid then
  3377. screen:expect{grid=[[
  3378. ## grid 1
  3379. [2:----------------------------------------]|
  3380. [2:----------------------------------------]|
  3381. [2:----------------------------------------]|
  3382. [2:----------------------------------------]|
  3383. [2:----------------------------------------]|
  3384. [2:----------------------------------------]|
  3385. [3:----------------------------------------]|
  3386. ## grid 2
  3387. |
  3388. |
  3389. |
  3390. ^ |
  3391. {0:~ }|
  3392. {0:~ }|
  3393. ## grid 3
  3394. |
  3395. ## grid 5
  3396. {1:1 }|
  3397. ## grid 6
  3398. {1:2 }|
  3399. ## grid 7
  3400. {1:3 }|
  3401. ## grid 8
  3402. {1:4 }|
  3403. ## grid 9
  3404. {1:5 }|
  3405. ## grid 10
  3406. {1:6 }|
  3407. ## grid 11
  3408. {1:7 }|
  3409. ## grid 12
  3410. {1:8 }|
  3411. ]], float_pos={
  3412. [5] = {{id = 1002}, "NW", 1, 1, 10, true, 50};
  3413. [6] = {{id = 1003}, "NW", 1, 1, 30, true, 50};
  3414. [7] = {{id = 1004}, "NE", 5, 1, 0, true, 50};
  3415. [8] = {{id = 1005}, "NE", 6, 1, 0, true, 50};
  3416. [9] = {{id = 1006}, "SE", 7, 0, 0, true, 50};
  3417. [10] = {{id = 1007}, "SE", 8, 0, 0, true, 50};
  3418. [11] = {{id = 1008}, "SW", 9, 0, 5, true, 50};
  3419. [12] = {{id = 1009}, "SW", 10, 0, 5, true, 50};
  3420. }}
  3421. else
  3422. screen:expect([[
  3423. {1:7 } {1:8 } |
  3424. {1:5 } {1:1 } {1:6 } {1:2 } |
  3425. {1:3 } {1:4 } |
  3426. ^ |
  3427. {0:~ }|
  3428. {0:~ }|
  3429. |
  3430. ]])
  3431. end
  3432. -- Reconfigure in different directions
  3433. exec([[
  3434. let o1 = extendnew(o1, #{anchor: 'NW'})
  3435. call nvim_win_set_config(w8, o1)
  3436. let o2 = extendnew(o2, #{anchor: 'NW'})
  3437. call nvim_win_set_config(w4, o2)
  3438. let o3 = extendnew(o3, #{win: w8})
  3439. call nvim_win_set_config(w2, o3)
  3440. let o4 = extendnew(o4, #{win: w4})
  3441. call nvim_win_set_config(w1, o4)
  3442. let o5 = extendnew(o5, #{win: w2})
  3443. call nvim_win_set_config(w6, o5)
  3444. let o6 = extendnew(o6, #{win: w1})
  3445. call nvim_win_set_config(w3, o6)
  3446. let o7 = extendnew(o7, #{win: w6})
  3447. call nvim_win_set_config(w5, o7)
  3448. let o8 = extendnew(o8, #{win: w3})
  3449. call nvim_win_set_config(w7, o8)
  3450. ]])
  3451. if multigrid then
  3452. screen:expect{grid=[[
  3453. ## grid 1
  3454. [2:----------------------------------------]|
  3455. [2:----------------------------------------]|
  3456. [2:----------------------------------------]|
  3457. [2:----------------------------------------]|
  3458. [2:----------------------------------------]|
  3459. [2:----------------------------------------]|
  3460. [3:----------------------------------------]|
  3461. ## grid 2
  3462. |
  3463. |
  3464. |
  3465. ^ |
  3466. {0:~ }|
  3467. {0:~ }|
  3468. ## grid 3
  3469. |
  3470. ## grid 5
  3471. {1:1 }|
  3472. ## grid 6
  3473. {1:2 }|
  3474. ## grid 7
  3475. {1:3 }|
  3476. ## grid 8
  3477. {1:4 }|
  3478. ## grid 9
  3479. {1:5 }|
  3480. ## grid 10
  3481. {1:6 }|
  3482. ## grid 11
  3483. {1:7 }|
  3484. ## grid 12
  3485. {1:8 }|
  3486. ]], float_pos={
  3487. [5] = {{id = 1002}, "NE", 8, 1, 0, true, 50};
  3488. [6] = {{id = 1003}, "NE", 12, 1, 0, true, 50};
  3489. [7] = {{id = 1004}, "SE", 5, 0, 0, true, 50};
  3490. [8] = {{id = 1005}, "NW", 1, 1, 30, true, 50};
  3491. [9] = {{id = 1006}, "SW", 10, 0, 5, true, 50};
  3492. [10] = {{id = 1007}, "SE", 6, 0, 0, true, 50};
  3493. [11] = {{id = 1008}, "SW", 7, 0, 5, true, 50};
  3494. [12] = {{id = 1009}, "NW", 1, 1, 10, true, 50};
  3495. }}
  3496. else
  3497. screen:expect([[
  3498. {1:5 } {1:7 } |
  3499. {1:6 } {1:8 } {1:3 } {1:4 } |
  3500. {1:2 } {1:1 } |
  3501. ^ |
  3502. {0:~ }|
  3503. {0:~ }|
  3504. |
  3505. ]])
  3506. end
  3507. -- Not clear how cycles should behave, but they should not hang or crash
  3508. exec([[
  3509. let o1 = extendnew(o1, #{relative: 'win', win: w7})
  3510. call nvim_win_set_config(w1, o1)
  3511. let o2 = extendnew(o2, #{relative: 'win', win: w8})
  3512. call nvim_win_set_config(w2, o2)
  3513. let o3 = extendnew(o3, #{win: w1})
  3514. call nvim_win_set_config(w3, o3)
  3515. let o4 = extendnew(o4, #{win: w2})
  3516. call nvim_win_set_config(w4, o4)
  3517. let o5 = extendnew(o5, #{win: w3})
  3518. call nvim_win_set_config(w5, o5)
  3519. let o6 = extendnew(o6, #{win: w4})
  3520. call nvim_win_set_config(w6, o6)
  3521. let o7 = extendnew(o7, #{win: w5})
  3522. call nvim_win_set_config(w7, o7)
  3523. let o8 = extendnew(o8, #{win: w6})
  3524. call nvim_win_set_config(w8, o8)
  3525. redraw
  3526. ]])
  3527. end)
  3528. it('can be placed relative text in a window', function()
  3529. screen:try_resize(30,5)
  3530. local firstwin = meths.get_current_win().id
  3531. meths.buf_set_lines(0, 0, -1, true, {'just some', 'example text that is wider than the window', '', '', 'more text'})
  3532. if multigrid then
  3533. screen:expect{grid=[[
  3534. ## grid 1
  3535. [2:------------------------------]|
  3536. [2:------------------------------]|
  3537. [2:------------------------------]|
  3538. [2:------------------------------]|
  3539. [3:------------------------------]|
  3540. ## grid 2
  3541. ^just some |
  3542. example text that is wider tha|
  3543. n the window |
  3544. |
  3545. ## grid 3
  3546. |
  3547. ]]}
  3548. else
  3549. screen:expect{grid=[[
  3550. ^just some |
  3551. example text that is wider tha|
  3552. n the window |
  3553. |
  3554. |
  3555. ]]}
  3556. end
  3557. local buf = meths.create_buf(false,false)
  3558. meths.buf_set_lines(buf, 0, -1, true, {'some info!'})
  3559. local win = meths.open_win(buf, false, {relative='win', width=12, height=1, bufpos={1,32}})
  3560. if multigrid then
  3561. screen:expect{grid=[[
  3562. ## grid 1
  3563. [2:------------------------------]|
  3564. [2:------------------------------]|
  3565. [2:------------------------------]|
  3566. [2:------------------------------]|
  3567. [3:------------------------------]|
  3568. ## grid 2
  3569. ^just some |
  3570. example text that is wider tha|
  3571. n the window |
  3572. |
  3573. ## grid 3
  3574. |
  3575. ## grid 5
  3576. {1:some info! }|
  3577. ]], float_pos={
  3578. [5] = { {
  3579. id = 1002
  3580. }, "NW", 2, 3, 2, true }
  3581. }}
  3582. else
  3583. screen:expect{grid=[[
  3584. ^just some |
  3585. example text that is wider tha|
  3586. n the window |
  3587. {1:some info! } |
  3588. |
  3589. ]]}
  3590. end
  3591. eq({relative='win', width=12, height=1, bufpos={1,32}, anchor='NW',
  3592. external=false, col=0, row=1, win=firstwin, focusable=true, zindex=50}, meths.win_get_config(win))
  3593. feed('<c-e>')
  3594. if multigrid then
  3595. screen:expect{grid=[[
  3596. ## grid 1
  3597. [2:------------------------------]|
  3598. [2:------------------------------]|
  3599. [2:------------------------------]|
  3600. [2:------------------------------]|
  3601. [3:------------------------------]|
  3602. ## grid 2
  3603. ^example text that is wider tha|
  3604. n the window |
  3605. |
  3606. |
  3607. ## grid 3
  3608. |
  3609. ## grid 5
  3610. {1:some info! }|
  3611. ]], float_pos={
  3612. [5] = { {
  3613. id = 1002
  3614. }, "NW", 2, 2, 2, true }
  3615. }}
  3616. else
  3617. screen:expect{grid=[[
  3618. ^example text that is wider tha|
  3619. n the window |
  3620. {1:some info! } |
  3621. |
  3622. |
  3623. ]]}
  3624. end
  3625. screen:try_resize(45,5)
  3626. if multigrid then
  3627. screen:expect{grid=[[
  3628. ## grid 1
  3629. [2:---------------------------------------------]|
  3630. [2:---------------------------------------------]|
  3631. [2:---------------------------------------------]|
  3632. [2:---------------------------------------------]|
  3633. [3:---------------------------------------------]|
  3634. ## grid 2
  3635. ^example text that is wider than the window |
  3636. |
  3637. |
  3638. more text |
  3639. ## grid 3
  3640. |
  3641. ## grid 5
  3642. {1:some info! }|
  3643. ]], float_pos={
  3644. [5] = { {
  3645. id = 1002
  3646. }, "NW", 2, 1, 32, true }
  3647. }}
  3648. else
  3649. -- note: appears misaligned due to cursor
  3650. screen:expect{grid=[[
  3651. ^example text that is wider than the window |
  3652. {1:some info! } |
  3653. |
  3654. more text |
  3655. |
  3656. ]]}
  3657. end
  3658. screen:try_resize(25,10)
  3659. if multigrid then
  3660. screen:expect{grid=[[
  3661. ## grid 1
  3662. [2:-------------------------]|
  3663. [2:-------------------------]|
  3664. [2:-------------------------]|
  3665. [2:-------------------------]|
  3666. [2:-------------------------]|
  3667. [2:-------------------------]|
  3668. [2:-------------------------]|
  3669. [2:-------------------------]|
  3670. [2:-------------------------]|
  3671. [3:-------------------------]|
  3672. ## grid 2
  3673. ^example text that is wide|
  3674. r than the window |
  3675. |
  3676. |
  3677. more text |
  3678. {0:~ }|
  3679. {0:~ }|
  3680. {0:~ }|
  3681. {0:~ }|
  3682. ## grid 3
  3683. |
  3684. ## grid 5
  3685. {1:some info! }|
  3686. ]], float_pos={
  3687. [5] = { {
  3688. id = 1002
  3689. }, "NW", 2, 2, 7, true }
  3690. }}
  3691. else
  3692. screen:expect{grid=[[
  3693. ^example text that is wide|
  3694. r than the window |
  3695. {1:some info! } |
  3696. |
  3697. more text |
  3698. {0:~ }|
  3699. {0:~ }|
  3700. {0:~ }|
  3701. {0:~ }|
  3702. |
  3703. ]]}
  3704. end
  3705. meths.win_set_config(win, {relative='win', bufpos={1,32}, anchor='SW'})
  3706. if multigrid then
  3707. screen:expect{grid=[[
  3708. ## grid 1
  3709. [2:-------------------------]|
  3710. [2:-------------------------]|
  3711. [2:-------------------------]|
  3712. [2:-------------------------]|
  3713. [2:-------------------------]|
  3714. [2:-------------------------]|
  3715. [2:-------------------------]|
  3716. [2:-------------------------]|
  3717. [2:-------------------------]|
  3718. [3:-------------------------]|
  3719. ## grid 2
  3720. ^example text that is wide|
  3721. r than the window |
  3722. |
  3723. |
  3724. more text |
  3725. {0:~ }|
  3726. {0:~ }|
  3727. {0:~ }|
  3728. {0:~ }|
  3729. ## grid 3
  3730. |
  3731. ## grid 5
  3732. {1:some info! }|
  3733. ]], float_pos={
  3734. [5] = { {
  3735. id = 1002
  3736. }, "SW", 2, 1, 7, true }
  3737. }}
  3738. else
  3739. screen:expect{grid=[[
  3740. ^example{1:some info! }s wide|
  3741. r than the window |
  3742. |
  3743. |
  3744. more text |
  3745. {0:~ }|
  3746. {0:~ }|
  3747. {0:~ }|
  3748. {0:~ }|
  3749. |
  3750. ]]}
  3751. end
  3752. command('set laststatus=0')
  3753. command('botright vnew')
  3754. if multigrid then
  3755. screen:expect{grid=[[
  3756. ## grid 1
  3757. [2:----]{5:│}[6:--------------------]|
  3758. [2:----]{5:│}[6:--------------------]|
  3759. [2:----]{5:│}[6:--------------------]|
  3760. [2:----]{5:│}[6:--------------------]|
  3761. [2:----]{5:│}[6:--------------------]|
  3762. [2:----]{5:│}[6:--------------------]|
  3763. [2:----]{5:│}[6:--------------------]|
  3764. [2:----]{5:│}[6:--------------------]|
  3765. [2:----]{5:│}[6:--------------------]|
  3766. [3:-------------------------]|
  3767. ## grid 2
  3768. exam|
  3769. ple |
  3770. text|
  3771. tha|
  3772. t is|
  3773. wid|
  3774. er t|
  3775. han |
  3776. the |
  3777. ## grid 3
  3778. |
  3779. ## grid 5
  3780. {1:some info! }|
  3781. ## grid 6
  3782. ^ |
  3783. {0:~ }|
  3784. {0:~ }|
  3785. {0:~ }|
  3786. {0:~ }|
  3787. {0:~ }|
  3788. {0:~ }|
  3789. {0:~ }|
  3790. {0:~ }|
  3791. ]], float_pos={
  3792. [5] = { {
  3793. id = 1002
  3794. }, "SW", 2, 8, 0, true }
  3795. }}
  3796. else
  3797. screen:expect{grid=[[
  3798. exam{5:│}^ |
  3799. ple {5:│}{0:~ }|
  3800. text{5:│}{0:~ }|
  3801. tha{5:│}{0:~ }|
  3802. t is{5:│}{0:~ }|
  3803. wid{5:│}{0:~ }|
  3804. er t{5:│}{0:~ }|
  3805. {1:some info! }{0: }|
  3806. the {5:│}{0:~ }|
  3807. |
  3808. ]]}
  3809. end
  3810. command('close')
  3811. meths.win_set_config(win, {relative='win', bufpos={1,32}, anchor='NW', col=-2})
  3812. if multigrid then
  3813. screen:expect{grid=[[
  3814. ## grid 1
  3815. [2:-------------------------]|
  3816. [2:-------------------------]|
  3817. [2:-------------------------]|
  3818. [2:-------------------------]|
  3819. [2:-------------------------]|
  3820. [2:-------------------------]|
  3821. [2:-------------------------]|
  3822. [2:-------------------------]|
  3823. [2:-------------------------]|
  3824. [3:-------------------------]|
  3825. ## grid 2
  3826. ^example text that is wide|
  3827. r than the window |
  3828. |
  3829. |
  3830. more text |
  3831. {0:~ }|
  3832. {0:~ }|
  3833. {0:~ }|
  3834. {0:~ }|
  3835. ## grid 3
  3836. |
  3837. ## grid 5
  3838. {1:some info! }|
  3839. ]], float_pos={
  3840. [5] = { {
  3841. id = 1002
  3842. }, "NW", 2, 2, 5, true }
  3843. }}
  3844. else
  3845. screen:expect{grid=[[
  3846. ^example text that is wide|
  3847. r than the window |
  3848. {1:some info! } |
  3849. |
  3850. more text |
  3851. {0:~ }|
  3852. {0:~ }|
  3853. {0:~ }|
  3854. {0:~ }|
  3855. |
  3856. ]]}
  3857. end
  3858. meths.win_set_config(win, {relative='win', bufpos={1,32}, row=2})
  3859. if multigrid then
  3860. screen:expect{grid=[[
  3861. ## grid 1
  3862. [2:-------------------------]|
  3863. [2:-------------------------]|
  3864. [2:-------------------------]|
  3865. [2:-------------------------]|
  3866. [2:-------------------------]|
  3867. [2:-------------------------]|
  3868. [2:-------------------------]|
  3869. [2:-------------------------]|
  3870. [2:-------------------------]|
  3871. [3:-------------------------]|
  3872. ## grid 2
  3873. ^example text that is wide|
  3874. r than the window |
  3875. |
  3876. |
  3877. more text |
  3878. {0:~ }|
  3879. {0:~ }|
  3880. {0:~ }|
  3881. {0:~ }|
  3882. ## grid 3
  3883. |
  3884. ## grid 5
  3885. {1:some info! }|
  3886. ]], float_pos={
  3887. [5] = { {
  3888. id = 1002
  3889. }, "NW", 2, 3, 7, true }
  3890. }}
  3891. else
  3892. screen:expect{grid=[[
  3893. ^example text that is wide|
  3894. r than the window |
  3895. |
  3896. {1:some info! } |
  3897. more text |
  3898. {0:~ }|
  3899. {0:~ }|
  3900. {0:~ }|
  3901. {0:~ }|
  3902. |
  3903. ]]}
  3904. end
  3905. command('%fold')
  3906. if multigrid then
  3907. screen:expect{grid=[[
  3908. ## grid 1
  3909. [2:-------------------------]|
  3910. [2:-------------------------]|
  3911. [2:-------------------------]|
  3912. [2:-------------------------]|
  3913. [2:-------------------------]|
  3914. [2:-------------------------]|
  3915. [2:-------------------------]|
  3916. [2:-------------------------]|
  3917. [2:-------------------------]|
  3918. [3:-------------------------]|
  3919. ## grid 2
  3920. {28:^+-- 5 lines: just some··}|
  3921. {0:~ }|
  3922. {0:~ }|
  3923. {0:~ }|
  3924. {0:~ }|
  3925. {0:~ }|
  3926. {0:~ }|
  3927. {0:~ }|
  3928. {0:~ }|
  3929. ## grid 3
  3930. |
  3931. ## grid 5
  3932. {1:some info! }|
  3933. ]], float_pos={
  3934. [5] = { {
  3935. id = 1002
  3936. }, "NW", 2, 2, 0, true }
  3937. }}
  3938. else
  3939. screen:expect{grid=[[
  3940. {28:^+-- 5 lines: just some··}|
  3941. {0:~ }|
  3942. {1:some info! }{0: }|
  3943. {0:~ }|
  3944. {0:~ }|
  3945. {0:~ }|
  3946. {0:~ }|
  3947. {0:~ }|
  3948. {0:~ }|
  3949. |
  3950. ]]}
  3951. end
  3952. end)
  3953. it('validates cursor even when window is not entered', function()
  3954. screen:try_resize(30,5)
  3955. command("set nowrap")
  3956. insert([[some text that is wider than the window]])
  3957. if multigrid then
  3958. screen:expect([[
  3959. ## grid 1
  3960. [2:------------------------------]|
  3961. [2:------------------------------]|
  3962. [2:------------------------------]|
  3963. [2:------------------------------]|
  3964. [3:------------------------------]|
  3965. ## grid 2
  3966. that is wider than the windo^w |
  3967. {0:~ }|
  3968. {0:~ }|
  3969. {0:~ }|
  3970. ## grid 3
  3971. |
  3972. ]])
  3973. else
  3974. screen:expect([[
  3975. that is wider than the windo^w |
  3976. {0:~ }|
  3977. {0:~ }|
  3978. {0:~ }|
  3979. |
  3980. ]])
  3981. end
  3982. local buf = meths.create_buf(false,true)
  3983. meths.buf_set_lines(buf, 0, -1, true, {'some floaty text'})
  3984. meths.open_win(buf, false, {relative='editor', width=20, height=1, row=3, col=1})
  3985. if multigrid then
  3986. screen:expect{grid=[[
  3987. ## grid 1
  3988. [2:------------------------------]|
  3989. [2:------------------------------]|
  3990. [2:------------------------------]|
  3991. [2:------------------------------]|
  3992. [3:------------------------------]|
  3993. ## grid 2
  3994. that is wider than the windo^w |
  3995. {0:~ }|
  3996. {0:~ }|
  3997. {0:~ }|
  3998. ## grid 3
  3999. |
  4000. ## grid 5
  4001. {1:some floaty text }|
  4002. ]], float_pos={
  4003. [5] = {{id = 1002}, "NW", 1, 3, 1, true}
  4004. }}
  4005. else
  4006. screen:expect([[
  4007. that is wider than the windo^w |
  4008. {0:~ }|
  4009. {0:~ }|
  4010. {0:~}{1:some floaty text }{0: }|
  4011. |
  4012. ]])
  4013. end
  4014. end)
  4015. if multigrid then
  4016. pending("supports second UI without multigrid", function()
  4017. local session2 = helpers.connect(eval('v:servername'))
  4018. print(session2:request("nvim_eval", "2+2"))
  4019. local screen2 = Screen.new(40,7)
  4020. screen2:attach(nil, session2)
  4021. screen2:set_default_attr_ids(attrs)
  4022. local buf = meths.create_buf(false,false)
  4023. meths.open_win(buf, true, {relative='editor', width=20, height=2, row=2, col=5})
  4024. local expected_pos = {
  4025. [2]={{id=1001}, 'NW', 1, 2, 5}
  4026. }
  4027. screen:expect{grid=[[
  4028. ## grid 1
  4029. |
  4030. {0:~ }|
  4031. {0:~ }|
  4032. {0:~ }|
  4033. {0:~ }|
  4034. {0:~ }|
  4035. |
  4036. ## grid 2
  4037. {1:^ }|
  4038. {2:~ }|
  4039. ]], float_pos=expected_pos}
  4040. screen2:expect([[
  4041. |
  4042. {0:~ }|
  4043. {0:~ }{1:^ }{0: }|
  4044. {0:~ }{2:~ }{0: }|
  4045. {0:~ }|
  4046. {0:~ }|
  4047. |
  4048. ]])
  4049. end)
  4050. end
  4051. it('handles resized screen', function()
  4052. local buf = meths.create_buf(false,false)
  4053. meths.buf_set_lines(buf, 0, -1, true, {'such', 'very', 'float'})
  4054. local win = meths.open_win(buf, false, {relative='editor', width=15, height=4, row=2, col=10})
  4055. local expected_pos = {
  4056. [5]={{id=1002}, 'NW', 1, 2, 10, true},
  4057. }
  4058. if multigrid then
  4059. screen:expect{grid=[[
  4060. ## grid 1
  4061. [2:----------------------------------------]|
  4062. [2:----------------------------------------]|
  4063. [2:----------------------------------------]|
  4064. [2:----------------------------------------]|
  4065. [2:----------------------------------------]|
  4066. [2:----------------------------------------]|
  4067. [3:----------------------------------------]|
  4068. ## grid 2
  4069. ^ |
  4070. {0:~ }|
  4071. {0:~ }|
  4072. {0:~ }|
  4073. {0:~ }|
  4074. {0:~ }|
  4075. ## grid 3
  4076. |
  4077. ## grid 5
  4078. {1:such }|
  4079. {1:very }|
  4080. {1:float }|
  4081. {2:~ }|
  4082. ]], float_pos=expected_pos}
  4083. else
  4084. screen:expect([[
  4085. ^ |
  4086. {0:~ }|
  4087. {0:~ }{1:such }{0: }|
  4088. {0:~ }{1:very }{0: }|
  4089. {0:~ }{1:float }{0: }|
  4090. {0:~ }{2:~ }{0: }|
  4091. |
  4092. ]])
  4093. end
  4094. screen:try_resize(40,5)
  4095. if multigrid then
  4096. screen:expect{grid=[[
  4097. ## grid 1
  4098. [2:----------------------------------------]|
  4099. [2:----------------------------------------]|
  4100. [2:----------------------------------------]|
  4101. [2:----------------------------------------]|
  4102. [3:----------------------------------------]|
  4103. ## grid 2
  4104. ^ |
  4105. {0:~ }|
  4106. {0:~ }|
  4107. {0:~ }|
  4108. ## grid 3
  4109. |
  4110. ## grid 5
  4111. {1:such }|
  4112. {1:very }|
  4113. {1:float }|
  4114. {2:~ }|
  4115. ]], float_pos=expected_pos}
  4116. else
  4117. screen:expect([[
  4118. ^ {1:such } |
  4119. {0:~ }{1:very }{0: }|
  4120. {0:~ }{1:float }{0: }|
  4121. {0:~ }{2:~ }{0: }|
  4122. |
  4123. ]])
  4124. end
  4125. screen:try_resize(40,4)
  4126. if multigrid then
  4127. screen:expect{grid=[[
  4128. ## grid 1
  4129. [2:----------------------------------------]|
  4130. [2:----------------------------------------]|
  4131. [2:----------------------------------------]|
  4132. [3:----------------------------------------]|
  4133. ## grid 2
  4134. ^ |
  4135. {0:~ }|
  4136. {0:~ }|
  4137. ## grid 3
  4138. |
  4139. ## grid 5
  4140. {1:such }|
  4141. {1:very }|
  4142. {1:float }|
  4143. {2:~ }|
  4144. ]], float_pos=expected_pos}
  4145. else
  4146. screen:expect([[
  4147. ^ {1:such } |
  4148. {0:~ }{1:very }{0: }|
  4149. {0:~ }{1:float }{0: }|
  4150. |
  4151. ]])
  4152. end
  4153. screen:try_resize(40,3)
  4154. if multigrid then
  4155. screen:expect{grid=[[
  4156. ## grid 1
  4157. [2:----------------------------------------]|
  4158. [2:----------------------------------------]|
  4159. [3:----------------------------------------]|
  4160. ## grid 2
  4161. ^ |
  4162. {0:~ }|
  4163. ## grid 3
  4164. |
  4165. ## grid 5
  4166. {1:such }|
  4167. {1:very }|
  4168. {1:float }|
  4169. {2:~ }|
  4170. ]], float_pos=expected_pos}
  4171. else
  4172. screen:expect([[
  4173. ^ {1:such } |
  4174. {0:~ }{1:very }{0: }|
  4175. |
  4176. ]])
  4177. end
  4178. feed('<c-w>wjj')
  4179. if multigrid then
  4180. screen:expect{grid=[[
  4181. ## grid 1
  4182. [2:----------------------------------------]|
  4183. [2:----------------------------------------]|
  4184. [3:----------------------------------------]|
  4185. ## grid 2
  4186. |
  4187. {0:~ }|
  4188. ## grid 3
  4189. |
  4190. ## grid 5
  4191. {1:such }|
  4192. {1:very }|
  4193. {1:^float }|
  4194. {2:~ }|
  4195. ]], float_pos=expected_pos}
  4196. else
  4197. screen:expect([[
  4198. {1:such } |
  4199. {0:~ }{1:very }{0: }|
  4200. ^ |
  4201. ]])
  4202. end
  4203. screen:try_resize(40,7)
  4204. if multigrid then
  4205. screen:expect{grid=[[
  4206. ## grid 1
  4207. [2:----------------------------------------]|
  4208. [2:----------------------------------------]|
  4209. [2:----------------------------------------]|
  4210. [2:----------------------------------------]|
  4211. [2:----------------------------------------]|
  4212. [2:----------------------------------------]|
  4213. [3:----------------------------------------]|
  4214. ## grid 2
  4215. |
  4216. {0:~ }|
  4217. {0:~ }|
  4218. {0:~ }|
  4219. {0:~ }|
  4220. {0:~ }|
  4221. ## grid 3
  4222. |
  4223. ## grid 5
  4224. {1:such }|
  4225. {1:very }|
  4226. {1:^float }|
  4227. {2:~ }|
  4228. ]], float_pos=expected_pos}
  4229. else
  4230. screen:expect([[
  4231. |
  4232. {0:~ }|
  4233. {0:~ }{1:such }{0: }|
  4234. {0:~ }{1:very }{0: }|
  4235. {0:~ }{1:^float }{0: }|
  4236. {0:~ }{2:~ }{0: }|
  4237. |
  4238. ]])
  4239. end
  4240. meths.win_set_config(win, {height=3})
  4241. feed('gg')
  4242. if multigrid then
  4243. screen:expect{grid=[[
  4244. ## grid 1
  4245. [2:----------------------------------------]|
  4246. [2:----------------------------------------]|
  4247. [2:----------------------------------------]|
  4248. [2:----------------------------------------]|
  4249. [2:----------------------------------------]|
  4250. [2:----------------------------------------]|
  4251. [3:----------------------------------------]|
  4252. ## grid 2
  4253. |
  4254. {0:~ }|
  4255. {0:~ }|
  4256. {0:~ }|
  4257. {0:~ }|
  4258. {0:~ }|
  4259. ## grid 3
  4260. |
  4261. ## grid 5
  4262. {1:^such }|
  4263. {1:very }|
  4264. {1:float }|
  4265. ]], float_pos=expected_pos}
  4266. else
  4267. screen:expect([[
  4268. |
  4269. {0:~ }|
  4270. {0:~ }{1:^such }{0: }|
  4271. {0:~ }{1:very }{0: }|
  4272. {0:~ }{1:float }{0: }|
  4273. {0:~ }|
  4274. |
  4275. ]])
  4276. end
  4277. screen:try_resize(26,7)
  4278. if multigrid then
  4279. screen:expect{grid=[[
  4280. ## grid 1
  4281. [2:--------------------------]|
  4282. [2:--------------------------]|
  4283. [2:--------------------------]|
  4284. [2:--------------------------]|
  4285. [2:--------------------------]|
  4286. [2:--------------------------]|
  4287. [3:--------------------------]|
  4288. ## grid 2
  4289. |
  4290. {0:~ }|
  4291. {0:~ }|
  4292. {0:~ }|
  4293. {0:~ }|
  4294. {0:~ }|
  4295. ## grid 3
  4296. |
  4297. ## grid 5
  4298. {1:^such }|
  4299. {1:very }|
  4300. {1:float }|
  4301. ]], float_pos=expected_pos}
  4302. else
  4303. screen:expect([[
  4304. |
  4305. {0:~ }|
  4306. {0:~ }{1:^such }{0: }|
  4307. {0:~ }{1:very }{0: }|
  4308. {0:~ }{1:float }{0: }|
  4309. {0:~ }|
  4310. |
  4311. ]])
  4312. end
  4313. screen:try_resize(25,7)
  4314. if multigrid then
  4315. screen:expect{grid=[[
  4316. ## grid 1
  4317. [2:-------------------------]|
  4318. [2:-------------------------]|
  4319. [2:-------------------------]|
  4320. [2:-------------------------]|
  4321. [2:-------------------------]|
  4322. [2:-------------------------]|
  4323. [3:-------------------------]|
  4324. ## grid 2
  4325. |
  4326. {0:~ }|
  4327. {0:~ }|
  4328. {0:~ }|
  4329. {0:~ }|
  4330. {0:~ }|
  4331. ## grid 3
  4332. |
  4333. ## grid 5
  4334. {1:^such }|
  4335. {1:very }|
  4336. {1:float }|
  4337. ]], float_pos=expected_pos}
  4338. else
  4339. screen:expect([[
  4340. |
  4341. {0:~ }|
  4342. {0:~ }{1:^such }|
  4343. {0:~ }{1:very }|
  4344. {0:~ }{1:float }|
  4345. {0:~ }|
  4346. |
  4347. ]])
  4348. end
  4349. screen:try_resize(24,7)
  4350. if multigrid then
  4351. screen:expect{grid=[[
  4352. ## grid 1
  4353. [2:------------------------]|
  4354. [2:------------------------]|
  4355. [2:------------------------]|
  4356. [2:------------------------]|
  4357. [2:------------------------]|
  4358. [2:------------------------]|
  4359. [3:------------------------]|
  4360. ## grid 2
  4361. |
  4362. {0:~ }|
  4363. {0:~ }|
  4364. {0:~ }|
  4365. {0:~ }|
  4366. {0:~ }|
  4367. ## grid 3
  4368. |
  4369. ## grid 5
  4370. {1:^such }|
  4371. {1:very }|
  4372. {1:float }|
  4373. ]], float_pos=expected_pos}
  4374. else
  4375. screen:expect([[
  4376. |
  4377. {0:~ }|
  4378. {0:~ }{1:^such }|
  4379. {0:~ }{1:very }|
  4380. {0:~ }{1:float }|
  4381. {0:~ }|
  4382. |
  4383. ]])
  4384. end
  4385. screen:try_resize(16,7)
  4386. if multigrid then
  4387. screen:expect{grid=[[
  4388. ## grid 1
  4389. [2:----------------]|
  4390. [2:----------------]|
  4391. [2:----------------]|
  4392. [2:----------------]|
  4393. [2:----------------]|
  4394. [2:----------------]|
  4395. [3:----------------]|
  4396. ## grid 2
  4397. |
  4398. {0:~ }|
  4399. {0:~ }|
  4400. {0:~ }|
  4401. {0:~ }|
  4402. {0:~ }|
  4403. ## grid 3
  4404. |
  4405. ## grid 5
  4406. {1:^such }|
  4407. {1:very }|
  4408. {1:float }|
  4409. ]], float_pos=expected_pos}
  4410. else
  4411. screen:expect([[
  4412. |
  4413. {0:~ }|
  4414. {0:~}{1:^such }|
  4415. {0:~}{1:very }|
  4416. {0:~}{1:float }|
  4417. {0:~ }|
  4418. |
  4419. ]])
  4420. end
  4421. screen:try_resize(15,7)
  4422. if multigrid then
  4423. screen:expect{grid=[[
  4424. ## grid 1
  4425. [2:---------------]|
  4426. [2:---------------]|
  4427. [2:---------------]|
  4428. [2:---------------]|
  4429. [2:---------------]|
  4430. [2:---------------]|
  4431. [3:---------------]|
  4432. ## grid 2
  4433. |
  4434. {0:~ }|
  4435. {0:~ }|
  4436. {0:~ }|
  4437. {0:~ }|
  4438. {0:~ }|
  4439. ## grid 3
  4440. |
  4441. ## grid 5
  4442. {1:^such }|
  4443. {1:very }|
  4444. {1:float }|
  4445. ]], float_pos=expected_pos}
  4446. else
  4447. screen:expect([[
  4448. |
  4449. {0:~ }|
  4450. {1:^such }|
  4451. {1:very }|
  4452. {1:float }|
  4453. {0:~ }|
  4454. |
  4455. ]])
  4456. end
  4457. screen:try_resize(14,7)
  4458. if multigrid then
  4459. screen:expect{grid=[[
  4460. ## grid 1
  4461. [2:--------------]|
  4462. [2:--------------]|
  4463. [2:--------------]|
  4464. [2:--------------]|
  4465. [2:--------------]|
  4466. [2:--------------]|
  4467. [3:--------------]|
  4468. ## grid 2
  4469. |
  4470. {0:~ }|
  4471. {0:~ }|
  4472. {0:~ }|
  4473. {0:~ }|
  4474. {0:~ }|
  4475. ## grid 3
  4476. |
  4477. ## grid 5
  4478. {1:^such }|
  4479. {1:very }|
  4480. {1:float }|
  4481. ]], float_pos=expected_pos}
  4482. else
  4483. screen:expect([[
  4484. |
  4485. {0:~ }|
  4486. {1:^such }|
  4487. {1:very }|
  4488. {1:float }|
  4489. {0:~ }|
  4490. |
  4491. ]])
  4492. end
  4493. screen:try_resize(12,7)
  4494. if multigrid then
  4495. screen:expect{grid=[[
  4496. ## grid 1
  4497. [2:------------]|
  4498. [2:------------]|
  4499. [2:------------]|
  4500. [2:------------]|
  4501. [2:------------]|
  4502. [2:------------]|
  4503. [3:------------]|
  4504. ## grid 2
  4505. |
  4506. {0:~ }|
  4507. {0:~ }|
  4508. {0:~ }|
  4509. {0:~ }|
  4510. {0:~ }|
  4511. ## grid 3
  4512. |
  4513. ## grid 5
  4514. {1:^such }|
  4515. {1:very }|
  4516. {1:float }|
  4517. ]], float_pos=expected_pos}
  4518. else
  4519. screen:expect([[
  4520. |
  4521. {0:~ }|
  4522. {1:^such }|
  4523. {1:very }|
  4524. {1:float }|
  4525. {0:~ }|
  4526. |
  4527. ]])
  4528. end
  4529. -- Doesn't make much sense, but check nvim doesn't crash
  4530. screen:try_resize(1,1)
  4531. if multigrid then
  4532. screen:expect{grid=[[
  4533. ## grid 1
  4534. [2:------------]|
  4535. [3:------------]|
  4536. ## grid 2
  4537. |
  4538. ## grid 3
  4539. |
  4540. ## grid 5
  4541. {1:^such }|
  4542. {1:very }|
  4543. {1:float }|
  4544. ]], float_pos=expected_pos}
  4545. else
  4546. screen:expect([[
  4547. {1:^such }|
  4548. |
  4549. ]])
  4550. end
  4551. screen:try_resize(40,7)
  4552. if multigrid then
  4553. screen:expect{grid=[[
  4554. ## grid 1
  4555. [2:----------------------------------------]|
  4556. [2:----------------------------------------]|
  4557. [2:----------------------------------------]|
  4558. [2:----------------------------------------]|
  4559. [2:----------------------------------------]|
  4560. [2:----------------------------------------]|
  4561. [3:----------------------------------------]|
  4562. ## grid 2
  4563. |
  4564. {0:~ }|
  4565. {0:~ }|
  4566. {0:~ }|
  4567. {0:~ }|
  4568. {0:~ }|
  4569. ## grid 3
  4570. |
  4571. ## grid 5
  4572. {1:^such }|
  4573. {1:very }|
  4574. {1:float }|
  4575. ]], float_pos=expected_pos}
  4576. else
  4577. screen:expect([[
  4578. |
  4579. {0:~ }|
  4580. {0:~ }{1:^such }{0: }|
  4581. {0:~ }{1:very }{0: }|
  4582. {0:~ }{1:float }{0: }|
  4583. {0:~ }|
  4584. |
  4585. ]])
  4586. end
  4587. end)
  4588. it('does not crash with inccommand #9379', function()
  4589. local expected_pos = {
  4590. [4]={{id=1001}, 'NW', 1, 2, 0, true},
  4591. }
  4592. command("set inccommand=split")
  4593. command("set laststatus=2")
  4594. local buf = meths.create_buf(false,false)
  4595. meths.open_win(buf, true, {relative='editor', width=30, height=3, row=2, col=0})
  4596. insert([[
  4597. foo
  4598. bar
  4599. ]])
  4600. if multigrid then
  4601. screen:expect{grid=[[
  4602. ## grid 1
  4603. [2:----------------------------------------]|
  4604. [2:----------------------------------------]|
  4605. [2:----------------------------------------]|
  4606. [2:----------------------------------------]|
  4607. [2:----------------------------------------]|
  4608. {5:[No Name] }|
  4609. [3:----------------------------------------]|
  4610. ## grid 2
  4611. |
  4612. {0:~ }|
  4613. {0:~ }|
  4614. {0:~ }|
  4615. {0:~ }|
  4616. ## grid 3
  4617. |
  4618. ## grid 4
  4619. {1:foo }|
  4620. {1:bar }|
  4621. {1:^ }|
  4622. ]], float_pos=expected_pos}
  4623. else
  4624. screen:expect([[
  4625. |
  4626. {0:~ }|
  4627. {1:foo }{0: }|
  4628. {1:bar }{0: }|
  4629. {1:^ }{0: }|
  4630. {5:[No Name] }|
  4631. |
  4632. ]])
  4633. end
  4634. feed(':%s/.')
  4635. if multigrid then
  4636. screen:expect{grid=[[
  4637. ## grid 1
  4638. [2:----------------------------------------]|
  4639. [2:----------------------------------------]|
  4640. [2:----------------------------------------]|
  4641. [2:----------------------------------------]|
  4642. [2:----------------------------------------]|
  4643. {5:[Preview] }|
  4644. [3:----------------------------------------]|
  4645. ## grid 2
  4646. |
  4647. ## grid 3
  4648. :%s/.^ |
  4649. ## grid 4
  4650. {17:f}{1:oo }|
  4651. {17:b}{1:ar }|
  4652. {1: }|
  4653. ]], float_pos=expected_pos}
  4654. else
  4655. screen:expect([[
  4656. |
  4657. {5:[No Name] }|
  4658. {17:f}{1:oo } |
  4659. {17:b}{1:ar } |
  4660. {1: }{0: }|
  4661. {5:[Preview] }|
  4662. :%s/.^ |
  4663. ]])
  4664. end
  4665. feed('<Esc>')
  4666. if multigrid then
  4667. screen:expect{grid=[[
  4668. ## grid 1
  4669. [2:----------------------------------------]|
  4670. [2:----------------------------------------]|
  4671. [2:----------------------------------------]|
  4672. [2:----------------------------------------]|
  4673. [2:----------------------------------------]|
  4674. {5:[No Name] }|
  4675. [3:----------------------------------------]|
  4676. ## grid 2
  4677. |
  4678. {0:~ }|
  4679. {0:~ }|
  4680. {0:~ }|
  4681. {0:~ }|
  4682. ## grid 3
  4683. |
  4684. ## grid 4
  4685. {1:foo }|
  4686. {1:bar }|
  4687. {1:^ }|
  4688. ]], float_pos=expected_pos}
  4689. else
  4690. screen:expect([[
  4691. |
  4692. {0:~ }|
  4693. {1:foo }{0: }|
  4694. {1:bar }{0: }|
  4695. {1:^ }{0: }|
  4696. {5:[No Name] }|
  4697. |
  4698. ]])
  4699. end
  4700. end)
  4701. it('does not crash when set cmdheight #9680', function()
  4702. local buf = meths.create_buf(false,false)
  4703. meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
  4704. command("set cmdheight=2")
  4705. eq(1, meths.eval('1'))
  4706. end)
  4707. describe('and completion', function()
  4708. before_each(function()
  4709. local buf = meths.create_buf(false,false)
  4710. local win = meths.open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5})
  4711. meths.win_set_option(win , 'winhl', 'Normal:ErrorMsg')
  4712. if multigrid then
  4713. screen:expect{grid=[[
  4714. ## grid 1
  4715. [2:----------------------------------------]|
  4716. [2:----------------------------------------]|
  4717. [2:----------------------------------------]|
  4718. [2:----------------------------------------]|
  4719. [2:----------------------------------------]|
  4720. [2:----------------------------------------]|
  4721. [3:----------------------------------------]|
  4722. ## grid 2
  4723. |
  4724. {0:~ }|
  4725. {0:~ }|
  4726. {0:~ }|
  4727. {0:~ }|
  4728. {0:~ }|
  4729. ## grid 3
  4730. |
  4731. ## grid 4
  4732. {7:^ }|
  4733. {12:~ }|
  4734. {12:~ }|
  4735. {12:~ }|
  4736. ]], float_pos={
  4737. [4] = {{ id = 1001 }, "NW", 1, 2, 5, true},
  4738. }}
  4739. else
  4740. screen:expect([[
  4741. |
  4742. {0:~ }|
  4743. {0:~ }{7:^ }{0: }|
  4744. {0:~ }{12:~ }{0: }|
  4745. {0:~ }{12:~ }{0: }|
  4746. {0:~ }{12:~ }{0: }|
  4747. |
  4748. ]])
  4749. end
  4750. end)
  4751. it('with builtin popupmenu', function()
  4752. feed('ix ')
  4753. funcs.complete(3, {'aa', 'word', 'longtext'})
  4754. if multigrid then
  4755. screen:expect{grid=[[
  4756. ## grid 1
  4757. [2:----------------------------------------]|
  4758. [2:----------------------------------------]|
  4759. [2:----------------------------------------]|
  4760. [2:----------------------------------------]|
  4761. [2:----------------------------------------]|
  4762. [2:----------------------------------------]|
  4763. [3:----------------------------------------]|
  4764. ## grid 2
  4765. |
  4766. {0:~ }|
  4767. {0:~ }|
  4768. {0:~ }|
  4769. {0:~ }|
  4770. {0:~ }|
  4771. ## grid 3
  4772. {3:-- INSERT --} |
  4773. ## grid 4
  4774. {7:x aa^ }|
  4775. {12:~ }|
  4776. {12:~ }|
  4777. {12:~ }|
  4778. ## grid 5
  4779. {13: aa }|
  4780. {1: word }|
  4781. {1: longtext }|
  4782. ]], float_pos={
  4783. [4] = {{ id = 1001 }, "NW", 1, 2, 5, true, 50},
  4784. [5] = {{ id = -1 }, "NW", 4, 1, 1, false, 100}
  4785. }}
  4786. else
  4787. screen:expect([[
  4788. |
  4789. {0:~ }|
  4790. {0:~ }{7:x aa^ }{0: }|
  4791. {0:~ }{12:~}{13: aa }{0: }|
  4792. {0:~ }{12:~}{1: word }{0: }|
  4793. {0:~ }{12:~}{1: longtext }{0: }|
  4794. {3:-- INSERT --} |
  4795. ]])
  4796. end
  4797. feed('<esc>')
  4798. if multigrid then
  4799. screen:expect{grid=[[
  4800. ## grid 1
  4801. [2:----------------------------------------]|
  4802. [2:----------------------------------------]|
  4803. [2:----------------------------------------]|
  4804. [2:----------------------------------------]|
  4805. [2:----------------------------------------]|
  4806. [2:----------------------------------------]|
  4807. [3:----------------------------------------]|
  4808. ## grid 2
  4809. |
  4810. {0:~ }|
  4811. {0:~ }|
  4812. {0:~ }|
  4813. {0:~ }|
  4814. {0:~ }|
  4815. ## grid 3
  4816. |
  4817. ## grid 4
  4818. {7:x a^a }|
  4819. {12:~ }|
  4820. {12:~ }|
  4821. {12:~ }|
  4822. ]], float_pos={
  4823. [4] = {{ id = 1001 }, "NW", 1, 2, 5, true},
  4824. }}
  4825. else
  4826. screen:expect([[
  4827. |
  4828. {0:~ }|
  4829. {0:~ }{7:x a^a }{0: }|
  4830. {0:~ }{12:~ }{0: }|
  4831. {0:~ }{12:~ }{0: }|
  4832. {0:~ }{12:~ }{0: }|
  4833. |
  4834. ]])
  4835. end
  4836. feed('<c-w>wi')
  4837. funcs.complete(1, {'xx', 'yy', 'zz'})
  4838. if multigrid then
  4839. screen:expect{grid=[[
  4840. ## grid 1
  4841. [2:----------------------------------------]|
  4842. [2:----------------------------------------]|
  4843. [2:----------------------------------------]|
  4844. [2:----------------------------------------]|
  4845. [2:----------------------------------------]|
  4846. [2:----------------------------------------]|
  4847. [3:----------------------------------------]|
  4848. ## grid 2
  4849. xx^ |
  4850. {0:~ }|
  4851. {0:~ }|
  4852. {0:~ }|
  4853. {0:~ }|
  4854. {0:~ }|
  4855. ## grid 3
  4856. {3:-- INSERT --} |
  4857. ## grid 4
  4858. {7:x aa }|
  4859. {12:~ }|
  4860. {12:~ }|
  4861. {12:~ }|
  4862. ## grid 5
  4863. {13:xx }|
  4864. {1:yy }|
  4865. {1:zz }|
  4866. ]], float_pos={
  4867. [4] = {{ id = 1001 }, "NW", 1, 2, 5, true, 50},
  4868. [5] = {{ id = -1 }, "NW", 2, 1, 0, false, 100}
  4869. }}
  4870. else
  4871. screen:expect([[
  4872. xx^ |
  4873. {13:xx }{0: }|
  4874. {1:yy }{7: }{0: }|
  4875. {1:zz }{12: }{0: }|
  4876. {0:~ }{12:~ }{0: }|
  4877. {0:~ }{12:~ }{0: }|
  4878. {3:-- INSERT --} |
  4879. ]])
  4880. end
  4881. feed('<c-y>')
  4882. if multigrid then
  4883. screen:expect{grid=[[
  4884. ## grid 1
  4885. [2:----------------------------------------]|
  4886. [2:----------------------------------------]|
  4887. [2:----------------------------------------]|
  4888. [2:----------------------------------------]|
  4889. [2:----------------------------------------]|
  4890. [2:----------------------------------------]|
  4891. [3:----------------------------------------]|
  4892. ## grid 2
  4893. xx^ |
  4894. {0:~ }|
  4895. {0:~ }|
  4896. {0:~ }|
  4897. {0:~ }|
  4898. {0:~ }|
  4899. ## grid 3
  4900. {3:-- INSERT --} |
  4901. ## grid 4
  4902. {7:x aa }|
  4903. {12:~ }|
  4904. {12:~ }|
  4905. {12:~ }|
  4906. ]], float_pos={
  4907. [4] = {{ id = 1001 }, "NW", 1, 2, 5, true},
  4908. }}
  4909. else
  4910. screen:expect([[
  4911. xx^ |
  4912. {0:~ }|
  4913. {0:~ }{7:x aa }{0: }|
  4914. {0:~ }{12:~ }{0: }|
  4915. {0:~ }{12:~ }{0: }|
  4916. {0:~ }{12:~ }{0: }|
  4917. {3:-- INSERT --} |
  4918. ]])
  4919. end
  4920. end)
  4921. it('command menu rendered above cursor (pum_above)', function()
  4922. command('set wildmenu wildmode=longest:full wildoptions=pum')
  4923. feed(':sign u<tab>')
  4924. if multigrid then
  4925. screen:expect{grid=[[
  4926. ## grid 1
  4927. [2:----------------------------------------]|
  4928. [2:----------------------------------------]|
  4929. [2:----------------------------------------]|
  4930. [2:----------------------------------------]|
  4931. [2:----------------------------------------]|
  4932. [2:----------------------------------------]|
  4933. [3:----------------------------------------]|
  4934. ## grid 2
  4935. |
  4936. {0:~ }|
  4937. {0:~ }|
  4938. {0:~ }|
  4939. {0:~ }|
  4940. {0:~ }|
  4941. ## grid 3
  4942. :sign un^ |
  4943. ## grid 4
  4944. {7: }|
  4945. {12:~ }|
  4946. {12:~ }|
  4947. {12:~ }|
  4948. ## grid 5
  4949. {1: undefine }|
  4950. {1: unplace }|
  4951. ]], float_pos={
  4952. [5] = {{id = -1}, "SW", 1, 6, 5, false, 250};
  4953. [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50};
  4954. }}
  4955. else
  4956. screen:expect{grid=[[
  4957. |
  4958. {0:~ }|
  4959. {0:~ }{7: }{0: }|
  4960. {0:~ }{12:~ }{0: }|
  4961. {0:~ }{1: undefine }{0: }|
  4962. {0:~ }{1: unplace }{0: }|
  4963. :sign un^ |
  4964. ]]}
  4965. end
  4966. end)
  4967. it('with ext_popupmenu', function()
  4968. screen:set_option('ext_popupmenu', true)
  4969. feed('ix ')
  4970. funcs.complete(3, {'aa', 'word', 'longtext'})
  4971. local items = {{"aa", "", "", ""}, {"word", "", "", ""}, {"longtext", "", "", ""}}
  4972. if multigrid then
  4973. screen:expect{grid=[[
  4974. ## grid 1
  4975. [2:----------------------------------------]|
  4976. [2:----------------------------------------]|
  4977. [2:----------------------------------------]|
  4978. [2:----------------------------------------]|
  4979. [2:----------------------------------------]|
  4980. [2:----------------------------------------]|
  4981. [3:----------------------------------------]|
  4982. ## grid 2
  4983. |
  4984. {0:~ }|
  4985. {0:~ }|
  4986. {0:~ }|
  4987. {0:~ }|
  4988. {0:~ }|
  4989. ## grid 3
  4990. {3:-- INSERT --} |
  4991. ## grid 4
  4992. {7:x aa^ }|
  4993. {12:~ }|
  4994. {12:~ }|
  4995. {12:~ }|
  4996. ]], float_pos={
  4997. [4] = {{ id = 1001 }, "NW", 1, 2, 5, true},
  4998. }, popupmenu={
  4999. anchor = {4, 0, 2}, items = items, pos = 0
  5000. }}
  5001. else
  5002. screen:expect{grid=[[
  5003. |
  5004. {0:~ }|
  5005. {0:~ }{7:x aa^ }{0: }|
  5006. {0:~ }{12:~ }{0: }|
  5007. {0:~ }{12:~ }{0: }|
  5008. {0:~ }{12:~ }{0: }|
  5009. {3:-- INSERT --} |
  5010. ]], popupmenu={
  5011. anchor = {1, 2, 7}, items = items, pos = 0
  5012. }}
  5013. end
  5014. feed('<esc>')
  5015. if multigrid then
  5016. screen:expect{grid=[[
  5017. ## grid 1
  5018. [2:----------------------------------------]|
  5019. [2:----------------------------------------]|
  5020. [2:----------------------------------------]|
  5021. [2:----------------------------------------]|
  5022. [2:----------------------------------------]|
  5023. [2:----------------------------------------]|
  5024. [3:----------------------------------------]|
  5025. ## grid 2
  5026. |
  5027. {0:~ }|
  5028. {0:~ }|
  5029. {0:~ }|
  5030. {0:~ }|
  5031. {0:~ }|
  5032. ## grid 3
  5033. |
  5034. ## grid 4
  5035. {7:x a^a }|
  5036. {12:~ }|
  5037. {12:~ }|
  5038. {12:~ }|
  5039. ]], float_pos={
  5040. [4] = {{ id = 1001 }, "NW", 1, 2, 5, true},
  5041. }}
  5042. else
  5043. screen:expect([[
  5044. |
  5045. {0:~ }|
  5046. {0:~ }{7:x a^a }{0: }|
  5047. {0:~ }{12:~ }{0: }|
  5048. {0:~ }{12:~ }{0: }|
  5049. {0:~ }{12:~ }{0: }|
  5050. |
  5051. ]])
  5052. end
  5053. feed('<c-w>wi')
  5054. funcs.complete(1, {'xx', 'yy', 'zz'})
  5055. items = {{"xx", "", "", ""}, {"yy", "", "", ""}, {"zz", "", "", ""}}
  5056. if multigrid then
  5057. screen:expect{grid=[[
  5058. ## grid 1
  5059. [2:----------------------------------------]|
  5060. [2:----------------------------------------]|
  5061. [2:----------------------------------------]|
  5062. [2:----------------------------------------]|
  5063. [2:----------------------------------------]|
  5064. [2:----------------------------------------]|
  5065. [3:----------------------------------------]|
  5066. ## grid 2
  5067. xx^ |
  5068. {0:~ }|
  5069. {0:~ }|
  5070. {0:~ }|
  5071. {0:~ }|
  5072. {0:~ }|
  5073. ## grid 3
  5074. {3:-- INSERT --} |
  5075. ## grid 4
  5076. {7:x aa }|
  5077. {12:~ }|
  5078. {12:~ }|
  5079. {12:~ }|
  5080. ]], float_pos={
  5081. [4] = {{ id = 1001 }, "NW", 1, 2, 5, true},
  5082. }, popupmenu={
  5083. anchor = {2, 0, 0}, items = items, pos = 0
  5084. }}
  5085. else
  5086. screen:expect{grid=[[
  5087. xx^ |
  5088. {0:~ }|
  5089. {0:~ }{7:x aa }{0: }|
  5090. {0:~ }{12:~ }{0: }|
  5091. {0:~ }{12:~ }{0: }|
  5092. {0:~ }{12:~ }{0: }|
  5093. {3:-- INSERT --} |
  5094. ]], popupmenu={
  5095. anchor = {1, 0, 0}, items = items, pos = 0
  5096. }}
  5097. end
  5098. feed('<c-y>')
  5099. if multigrid then
  5100. screen:expect{grid=[[
  5101. ## grid 1
  5102. [2:----------------------------------------]|
  5103. [2:----------------------------------------]|
  5104. [2:----------------------------------------]|
  5105. [2:----------------------------------------]|
  5106. [2:----------------------------------------]|
  5107. [2:----------------------------------------]|
  5108. [3:----------------------------------------]|
  5109. ## grid 2
  5110. xx^ |
  5111. {0:~ }|
  5112. {0:~ }|
  5113. {0:~ }|
  5114. {0:~ }|
  5115. {0:~ }|
  5116. ## grid 3
  5117. {3:-- INSERT --} |
  5118. ## grid 4
  5119. {7:x aa }|
  5120. {12:~ }|
  5121. {12:~ }|
  5122. {12:~ }|
  5123. ]], float_pos={
  5124. [4] = {{ id = 1001 }, "NW", 1, 2, 5, true},
  5125. }}
  5126. else
  5127. screen:expect([[
  5128. xx^ |
  5129. {0:~ }|
  5130. {0:~ }{7:x aa }{0: }|
  5131. {0:~ }{12:~ }{0: }|
  5132. {0:~ }{12:~ }{0: }|
  5133. {0:~ }{12:~ }{0: }|
  5134. {3:-- INSERT --} |
  5135. ]])
  5136. end
  5137. end)
  5138. end)
  5139. describe('float shown after pum', function()
  5140. local win
  5141. before_each(function()
  5142. command('hi NormalFloat guibg=#333333')
  5143. feed('i')
  5144. funcs.complete(1, {'aa', 'word', 'longtext'})
  5145. if multigrid then
  5146. screen:expect{grid=[[
  5147. ## grid 1
  5148. [2:----------------------------------------]|
  5149. [2:----------------------------------------]|
  5150. [2:----------------------------------------]|
  5151. [2:----------------------------------------]|
  5152. [2:----------------------------------------]|
  5153. [2:----------------------------------------]|
  5154. [3:----------------------------------------]|
  5155. ## grid 2
  5156. aa^ |
  5157. {0:~ }|
  5158. {0:~ }|
  5159. {0:~ }|
  5160. {0:~ }|
  5161. {0:~ }|
  5162. ## grid 3
  5163. {3:-- INSERT --} |
  5164. ## grid 4
  5165. {13:aa }|
  5166. {1:word }|
  5167. {1:longtext }|
  5168. ]], float_pos={
  5169. [4] = {{id = -1}, "NW", 2, 1, 0, false, 100}}
  5170. }
  5171. else
  5172. screen:expect([[
  5173. aa^ |
  5174. {13:aa }{0: }|
  5175. {1:word }{0: }|
  5176. {1:longtext }{0: }|
  5177. {0:~ }|
  5178. {0:~ }|
  5179. {3:-- INSERT --} |
  5180. ]])
  5181. end
  5182. local buf = meths.create_buf(false,true)
  5183. meths.buf_set_lines(buf,0,-1,true,{"some info", "about item"})
  5184. win = meths.open_win(buf, false, {relative='cursor', width=12, height=2, row=1, col=10})
  5185. if multigrid then
  5186. screen:expect{grid=[[
  5187. ## grid 1
  5188. [2:----------------------------------------]|
  5189. [2:----------------------------------------]|
  5190. [2:----------------------------------------]|
  5191. [2:----------------------------------------]|
  5192. [2:----------------------------------------]|
  5193. [2:----------------------------------------]|
  5194. [3:----------------------------------------]|
  5195. ## grid 2
  5196. aa^ |
  5197. {0:~ }|
  5198. {0:~ }|
  5199. {0:~ }|
  5200. {0:~ }|
  5201. {0:~ }|
  5202. ## grid 3
  5203. {3:-- INSERT --} |
  5204. ## grid 4
  5205. {13:aa }|
  5206. {1:word }|
  5207. {1:longtext }|
  5208. ## grid 6
  5209. {15:some info }|
  5210. {15:about item }|
  5211. ]], float_pos={
  5212. [4] = {{id = -1}, "NW", 2, 1, 0, false, 100},
  5213. [6] = {{id = 1002}, "NW", 2, 1, 12, true, 50},
  5214. }}
  5215. else
  5216. screen:expect([[
  5217. aa^ |
  5218. {13:aa }{15:e info }{0: }|
  5219. {1:word }{15:ut item }{0: }|
  5220. {1:longtext }{0: }|
  5221. {0:~ }|
  5222. {0:~ }|
  5223. {3:-- INSERT --} |
  5224. ]])
  5225. end
  5226. end)
  5227. it('and close pum first', function()
  5228. feed('<c-y>')
  5229. if multigrid then
  5230. screen:expect{grid=[[
  5231. ## grid 1
  5232. [2:----------------------------------------]|
  5233. [2:----------------------------------------]|
  5234. [2:----------------------------------------]|
  5235. [2:----------------------------------------]|
  5236. [2:----------------------------------------]|
  5237. [2:----------------------------------------]|
  5238. [3:----------------------------------------]|
  5239. ## grid 2
  5240. aa^ |
  5241. {0:~ }|
  5242. {0:~ }|
  5243. {0:~ }|
  5244. {0:~ }|
  5245. {0:~ }|
  5246. ## grid 3
  5247. {3:-- INSERT --} |
  5248. ## grid 6
  5249. {15:some info }|
  5250. {15:about item }|
  5251. ]], float_pos={
  5252. [6] = {{id = 1002}, "NW", 2, 1, 12, true},
  5253. }}
  5254. else
  5255. screen:expect([[
  5256. aa^ |
  5257. {0:~ }{15:some info }{0: }|
  5258. {0:~ }{15:about item }{0: }|
  5259. {0:~ }|
  5260. {0:~ }|
  5261. {0:~ }|
  5262. {3:-- INSERT --} |
  5263. ]])
  5264. end
  5265. meths.win_close(win, false)
  5266. if multigrid then
  5267. screen:expect([[
  5268. ## grid 1
  5269. [2:----------------------------------------]|
  5270. [2:----------------------------------------]|
  5271. [2:----------------------------------------]|
  5272. [2:----------------------------------------]|
  5273. [2:----------------------------------------]|
  5274. [2:----------------------------------------]|
  5275. [3:----------------------------------------]|
  5276. ## grid 2
  5277. aa^ |
  5278. {0:~ }|
  5279. {0:~ }|
  5280. {0:~ }|
  5281. {0:~ }|
  5282. {0:~ }|
  5283. ## grid 3
  5284. {3:-- INSERT --} |
  5285. ]])
  5286. else
  5287. screen:expect([[
  5288. aa^ |
  5289. {0:~ }|
  5290. {0:~ }|
  5291. {0:~ }|
  5292. {0:~ }|
  5293. {0:~ }|
  5294. {3:-- INSERT --} |
  5295. ]])
  5296. end
  5297. end)
  5298. it('and close float first', function()
  5299. meths.win_close(win, false)
  5300. if multigrid then
  5301. screen:expect{grid=[[
  5302. ## grid 1
  5303. [2:----------------------------------------]|
  5304. [2:----------------------------------------]|
  5305. [2:----------------------------------------]|
  5306. [2:----------------------------------------]|
  5307. [2:----------------------------------------]|
  5308. [2:----------------------------------------]|
  5309. [3:----------------------------------------]|
  5310. ## grid 2
  5311. aa^ |
  5312. {0:~ }|
  5313. {0:~ }|
  5314. {0:~ }|
  5315. {0:~ }|
  5316. {0:~ }|
  5317. ## grid 3
  5318. {3:-- INSERT --} |
  5319. ## grid 4
  5320. {13:aa }|
  5321. {1:word }|
  5322. {1:longtext }|
  5323. ]], float_pos={
  5324. [4] = {{id = -1}, "NW", 2, 1, 0, false, 100},
  5325. }}
  5326. else
  5327. screen:expect([[
  5328. aa^ |
  5329. {13:aa }{0: }|
  5330. {1:word }{0: }|
  5331. {1:longtext }{0: }|
  5332. {0:~ }|
  5333. {0:~ }|
  5334. {3:-- INSERT --} |
  5335. ]])
  5336. end
  5337. feed('<c-y>')
  5338. if multigrid then
  5339. screen:expect([[
  5340. ## grid 1
  5341. [2:----------------------------------------]|
  5342. [2:----------------------------------------]|
  5343. [2:----------------------------------------]|
  5344. [2:----------------------------------------]|
  5345. [2:----------------------------------------]|
  5346. [2:----------------------------------------]|
  5347. [3:----------------------------------------]|
  5348. ## grid 2
  5349. aa^ |
  5350. {0:~ }|
  5351. {0:~ }|
  5352. {0:~ }|
  5353. {0:~ }|
  5354. {0:~ }|
  5355. ## grid 3
  5356. {3:-- INSERT --} |
  5357. ]])
  5358. else
  5359. screen:expect([[
  5360. aa^ |
  5361. {0:~ }|
  5362. {0:~ }|
  5363. {0:~ }|
  5364. {0:~ }|
  5365. {0:~ }|
  5366. {3:-- INSERT --} |
  5367. ]])
  5368. end
  5369. end)
  5370. end)
  5371. it("can use Normal as background", function()
  5372. local buf = meths.create_buf(false,false)
  5373. meths.buf_set_lines(buf,0,-1,true,{"here", "float"})
  5374. local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
  5375. meths.set_option_value('winhl', 'Normal:Normal', {win=win})
  5376. if multigrid then
  5377. screen:expect{grid=[[
  5378. ## grid 1
  5379. [2:----------------------------------------]|
  5380. [2:----------------------------------------]|
  5381. [2:----------------------------------------]|
  5382. [2:----------------------------------------]|
  5383. [2:----------------------------------------]|
  5384. [2:----------------------------------------]|
  5385. [3:----------------------------------------]|
  5386. ## grid 2
  5387. ^ |
  5388. {0:~ }|
  5389. {0:~ }|
  5390. {0:~ }|
  5391. {0:~ }|
  5392. {0:~ }|
  5393. ## grid 3
  5394. |
  5395. ## grid 5
  5396. here |
  5397. float |
  5398. ]], float_pos={
  5399. [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50};
  5400. }, win_viewport={
  5401. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  5402. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0};
  5403. }}
  5404. else
  5405. screen:expect{grid=[[
  5406. ^ |
  5407. {0:~ }|
  5408. {0:~ }here {0: }|
  5409. {0:~ }float {0: }|
  5410. {0:~ }|
  5411. {0:~ }|
  5412. |
  5413. ]]}
  5414. end
  5415. end)
  5416. describe("handles :wincmd", function()
  5417. local win
  5418. local expected_pos
  5419. before_each(function()
  5420. -- the default, but be explicit:
  5421. command("set laststatus=1")
  5422. command("set hidden")
  5423. meths.buf_set_lines(0,0,-1,true,{"x"})
  5424. local buf = meths.create_buf(false,false)
  5425. win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
  5426. meths.buf_set_lines(buf,0,-1,true,{"y"})
  5427. expected_pos = {
  5428. [4]={{id=1001}, 'NW', 1, 2, 5, true}
  5429. }
  5430. if multigrid then
  5431. screen:expect{grid=[[
  5432. ## grid 1
  5433. [2:----------------------------------------]|
  5434. [2:----------------------------------------]|
  5435. [2:----------------------------------------]|
  5436. [2:----------------------------------------]|
  5437. [2:----------------------------------------]|
  5438. [2:----------------------------------------]|
  5439. [3:----------------------------------------]|
  5440. ## grid 2
  5441. ^x |
  5442. {0:~ }|
  5443. {0:~ }|
  5444. {0:~ }|
  5445. {0:~ }|
  5446. {0:~ }|
  5447. ## grid 3
  5448. |
  5449. ## grid 4
  5450. {1:y }|
  5451. {2:~ }|
  5452. ]], float_pos=expected_pos}
  5453. else
  5454. screen:expect([[
  5455. ^x |
  5456. {0:~ }|
  5457. {0:~ }{1:y }{0: }|
  5458. {0:~ }{2:~ }{0: }|
  5459. {0:~ }|
  5460. {0:~ }|
  5461. |
  5462. ]])
  5463. end
  5464. end)
  5465. it("w", function()
  5466. feed("<c-w>w")
  5467. if multigrid then
  5468. screen:expect{grid=[[
  5469. ## grid 1
  5470. [2:----------------------------------------]|
  5471. [2:----------------------------------------]|
  5472. [2:----------------------------------------]|
  5473. [2:----------------------------------------]|
  5474. [2:----------------------------------------]|
  5475. [2:----------------------------------------]|
  5476. [3:----------------------------------------]|
  5477. ## grid 2
  5478. x |
  5479. {0:~ }|
  5480. {0:~ }|
  5481. {0:~ }|
  5482. {0:~ }|
  5483. {0:~ }|
  5484. ## grid 3
  5485. |
  5486. ## grid 4
  5487. {1:^y }|
  5488. {2:~ }|
  5489. ]], float_pos=expected_pos}
  5490. else
  5491. screen:expect([[
  5492. x |
  5493. {0:~ }|
  5494. {0:~ }{1:^y }{0: }|
  5495. {0:~ }{2:~ }{0: }|
  5496. {0:~ }|
  5497. {0:~ }|
  5498. |
  5499. ]])
  5500. end
  5501. feed("<c-w>w")
  5502. if multigrid then
  5503. screen:expect{grid=[[
  5504. ## grid 1
  5505. [2:----------------------------------------]|
  5506. [2:----------------------------------------]|
  5507. [2:----------------------------------------]|
  5508. [2:----------------------------------------]|
  5509. [2:----------------------------------------]|
  5510. [2:----------------------------------------]|
  5511. [3:----------------------------------------]|
  5512. ## grid 2
  5513. ^x |
  5514. {0:~ }|
  5515. {0:~ }|
  5516. {0:~ }|
  5517. {0:~ }|
  5518. {0:~ }|
  5519. ## grid 3
  5520. |
  5521. ## grid 4
  5522. {1:y }|
  5523. {2:~ }|
  5524. ]], float_pos=expected_pos}
  5525. else
  5526. screen:expect([[
  5527. ^x |
  5528. {0:~ }|
  5529. {0:~ }{1:y }{0: }|
  5530. {0:~ }{2:~ }{0: }|
  5531. {0:~ }|
  5532. {0:~ }|
  5533. |
  5534. ]])
  5535. end
  5536. end)
  5537. it("w with focusable=false", function()
  5538. meths.win_set_config(win, {focusable=false})
  5539. expected_pos[4][6] = false
  5540. feed("<c-w>wi") -- i to provoke redraw
  5541. if multigrid then
  5542. screen:expect{grid=[[
  5543. ## grid 1
  5544. [2:----------------------------------------]|
  5545. [2:----------------------------------------]|
  5546. [2:----------------------------------------]|
  5547. [2:----------------------------------------]|
  5548. [2:----------------------------------------]|
  5549. [2:----------------------------------------]|
  5550. [3:----------------------------------------]|
  5551. ## grid 2
  5552. ^x |
  5553. {0:~ }|
  5554. {0:~ }|
  5555. {0:~ }|
  5556. {0:~ }|
  5557. {0:~ }|
  5558. ## grid 3
  5559. {3:-- INSERT --} |
  5560. ## grid 4
  5561. {1:y }|
  5562. {2:~ }|
  5563. ]], float_pos=expected_pos}
  5564. else
  5565. screen:expect([[
  5566. ^x |
  5567. {0:~ }|
  5568. {0:~ }{1:y }{0: }|
  5569. {0:~ }{2:~ }{0: }|
  5570. {0:~ }|
  5571. {0:~ }|
  5572. {3:-- INSERT --} |
  5573. ]])
  5574. end
  5575. feed("<esc><c-w>w")
  5576. if multigrid then
  5577. screen:expect{grid=[[
  5578. ## grid 1
  5579. [2:----------------------------------------]|
  5580. [2:----------------------------------------]|
  5581. [2:----------------------------------------]|
  5582. [2:----------------------------------------]|
  5583. [2:----------------------------------------]|
  5584. [2:----------------------------------------]|
  5585. [3:----------------------------------------]|
  5586. ## grid 2
  5587. ^x |
  5588. {0:~ }|
  5589. {0:~ }|
  5590. {0:~ }|
  5591. {0:~ }|
  5592. {0:~ }|
  5593. ## grid 3
  5594. |
  5595. ## grid 4
  5596. {1:y }|
  5597. {2:~ }|
  5598. ]], float_pos=expected_pos}
  5599. else
  5600. screen:expect([[
  5601. ^x |
  5602. {0:~ }|
  5603. {0:~ }{1:y }{0: }|
  5604. {0:~ }{2:~ }{0: }|
  5605. {0:~ }|
  5606. {0:~ }|
  5607. |
  5608. ]])
  5609. end
  5610. end)
  5611. it("W", function()
  5612. feed("<c-w>W")
  5613. if multigrid then
  5614. screen:expect{grid=[[
  5615. ## grid 1
  5616. [2:----------------------------------------]|
  5617. [2:----------------------------------------]|
  5618. [2:----------------------------------------]|
  5619. [2:----------------------------------------]|
  5620. [2:----------------------------------------]|
  5621. [2:----------------------------------------]|
  5622. [3:----------------------------------------]|
  5623. ## grid 2
  5624. x |
  5625. {0:~ }|
  5626. {0:~ }|
  5627. {0:~ }|
  5628. {0:~ }|
  5629. {0:~ }|
  5630. ## grid 3
  5631. |
  5632. ## grid 4
  5633. {1:^y }|
  5634. {2:~ }|
  5635. ]], float_pos=expected_pos}
  5636. else
  5637. screen:expect([[
  5638. x |
  5639. {0:~ }|
  5640. {0:~ }{1:^y }{0: }|
  5641. {0:~ }{2:~ }{0: }|
  5642. {0:~ }|
  5643. {0:~ }|
  5644. |
  5645. ]])
  5646. end
  5647. feed("<c-w>W")
  5648. if multigrid then
  5649. screen:expect{grid=[[
  5650. ## grid 1
  5651. [2:----------------------------------------]|
  5652. [2:----------------------------------------]|
  5653. [2:----------------------------------------]|
  5654. [2:----------------------------------------]|
  5655. [2:----------------------------------------]|
  5656. [2:----------------------------------------]|
  5657. [3:----------------------------------------]|
  5658. ## grid 2
  5659. ^x |
  5660. {0:~ }|
  5661. {0:~ }|
  5662. {0:~ }|
  5663. {0:~ }|
  5664. {0:~ }|
  5665. ## grid 3
  5666. |
  5667. ## grid 4
  5668. {1:y }|
  5669. {2:~ }|
  5670. ]], float_pos=expected_pos}
  5671. else
  5672. screen:expect([[
  5673. ^x |
  5674. {0:~ }|
  5675. {0:~ }{1:y }{0: }|
  5676. {0:~ }{2:~ }{0: }|
  5677. {0:~ }|
  5678. {0:~ }|
  5679. |
  5680. ]])
  5681. end
  5682. end)
  5683. it("focus by mouse", function()
  5684. if multigrid then
  5685. meths.input_mouse('left', 'press', '', 4, 0, 0)
  5686. screen:expect{grid=[[
  5687. ## grid 1
  5688. [2:----------------------------------------]|
  5689. [2:----------------------------------------]|
  5690. [2:----------------------------------------]|
  5691. [2:----------------------------------------]|
  5692. [2:----------------------------------------]|
  5693. [2:----------------------------------------]|
  5694. [3:----------------------------------------]|
  5695. ## grid 2
  5696. x |
  5697. {0:~ }|
  5698. {0:~ }|
  5699. {0:~ }|
  5700. {0:~ }|
  5701. {0:~ }|
  5702. ## grid 3
  5703. |
  5704. ## grid 4
  5705. {1:^y }|
  5706. {2:~ }|
  5707. ]], float_pos=expected_pos}
  5708. else
  5709. meths.input_mouse('left', 'press', '', 0, 2, 5)
  5710. screen:expect([[
  5711. x |
  5712. {0:~ }|
  5713. {0:~ }{1:^y }{0: }|
  5714. {0:~ }{2:~ }{0: }|
  5715. {0:~ }|
  5716. {0:~ }|
  5717. |
  5718. ]])
  5719. end
  5720. if multigrid then
  5721. meths.input_mouse('left', 'press', '', 1, 0, 0)
  5722. screen:expect{grid=[[
  5723. ## grid 1
  5724. [2:----------------------------------------]|
  5725. [2:----------------------------------------]|
  5726. [2:----------------------------------------]|
  5727. [2:----------------------------------------]|
  5728. [2:----------------------------------------]|
  5729. [2:----------------------------------------]|
  5730. [3:----------------------------------------]|
  5731. ## grid 2
  5732. ^x |
  5733. {0:~ }|
  5734. {0:~ }|
  5735. {0:~ }|
  5736. {0:~ }|
  5737. {0:~ }|
  5738. ## grid 3
  5739. |
  5740. ## grid 4
  5741. {1:y }|
  5742. {2:~ }|
  5743. ]], float_pos=expected_pos}
  5744. else
  5745. meths.input_mouse('left', 'press', '', 0, 0, 0)
  5746. screen:expect([[
  5747. ^x |
  5748. {0:~ }|
  5749. {0:~ }{1:y }{0: }|
  5750. {0:~ }{2:~ }{0: }|
  5751. {0:~ }|
  5752. {0:~ }|
  5753. |
  5754. ]])
  5755. end
  5756. end)
  5757. it("focus by mouse (focusable=false)", function()
  5758. meths.win_set_config(win, {focusable=false})
  5759. meths.buf_set_lines(0, -1, -1, true, {"a"})
  5760. expected_pos[4][6] = false
  5761. if multigrid then
  5762. meths.input_mouse('left', 'press', '', 4, 0, 0)
  5763. screen:expect{grid=[[
  5764. ## grid 1
  5765. [2:----------------------------------------]|
  5766. [2:----------------------------------------]|
  5767. [2:----------------------------------------]|
  5768. [2:----------------------------------------]|
  5769. [2:----------------------------------------]|
  5770. [2:----------------------------------------]|
  5771. [3:----------------------------------------]|
  5772. ## grid 2
  5773. ^x |
  5774. a |
  5775. {0:~ }|
  5776. {0:~ }|
  5777. {0:~ }|
  5778. {0:~ }|
  5779. ## grid 3
  5780. |
  5781. ## grid 4
  5782. {1:y }|
  5783. {2:~ }|
  5784. ]], float_pos=expected_pos}
  5785. else
  5786. meths.input_mouse('left', 'press', '', 0, 2, 5)
  5787. screen:expect([[
  5788. x |
  5789. ^a |
  5790. {0:~ }{1:y }{0: }|
  5791. {0:~ }{2:~ }{0: }|
  5792. {0:~ }|
  5793. {0:~ }|
  5794. |
  5795. ]])
  5796. end
  5797. if multigrid then
  5798. meths.input_mouse('left', 'press', '', 1, 0, 0)
  5799. screen:expect{grid=[[
  5800. ## grid 1
  5801. [2:----------------------------------------]|
  5802. [2:----------------------------------------]|
  5803. [2:----------------------------------------]|
  5804. [2:----------------------------------------]|
  5805. [2:----------------------------------------]|
  5806. [2:----------------------------------------]|
  5807. [3:----------------------------------------]|
  5808. ## grid 2
  5809. ^x |
  5810. a |
  5811. {0:~ }|
  5812. {0:~ }|
  5813. {0:~ }|
  5814. {0:~ }|
  5815. ## grid 3
  5816. |
  5817. ## grid 4
  5818. {1:y }|
  5819. {2:~ }|
  5820. ]], float_pos=expected_pos, unchanged=true}
  5821. else
  5822. meths.input_mouse('left', 'press', '', 0, 0, 0)
  5823. screen:expect([[
  5824. ^x |
  5825. a |
  5826. {0:~ }{1:y }{0: }|
  5827. {0:~ }{2:~ }{0: }|
  5828. {0:~ }|
  5829. {0:~ }|
  5830. |
  5831. ]])
  5832. end
  5833. end)
  5834. it("j", function()
  5835. feed("<c-w>ji") -- INSERT to trigger screen change
  5836. if multigrid then
  5837. screen:expect{grid=[[
  5838. ## grid 1
  5839. [2:----------------------------------------]|
  5840. [2:----------------------------------------]|
  5841. [2:----------------------------------------]|
  5842. [2:----------------------------------------]|
  5843. [2:----------------------------------------]|
  5844. [2:----------------------------------------]|
  5845. [3:----------------------------------------]|
  5846. ## grid 2
  5847. ^x |
  5848. {0:~ }|
  5849. {0:~ }|
  5850. {0:~ }|
  5851. {0:~ }|
  5852. {0:~ }|
  5853. ## grid 3
  5854. {3:-- INSERT --} |
  5855. ## grid 4
  5856. {1:y }|
  5857. {2:~ }|
  5858. ]], float_pos=expected_pos}
  5859. else
  5860. screen:expect([[
  5861. ^x |
  5862. {0:~ }|
  5863. {0:~ }{1:y }{0: }|
  5864. {0:~ }{2:~ }{0: }|
  5865. {0:~ }|
  5866. {0:~ }|
  5867. {3:-- INSERT --} |
  5868. ]])
  5869. end
  5870. feed("<esc><c-w>w")
  5871. if multigrid then
  5872. screen:expect{grid=[[
  5873. ## grid 1
  5874. [2:----------------------------------------]|
  5875. [2:----------------------------------------]|
  5876. [2:----------------------------------------]|
  5877. [2:----------------------------------------]|
  5878. [2:----------------------------------------]|
  5879. [2:----------------------------------------]|
  5880. [3:----------------------------------------]|
  5881. ## grid 2
  5882. x |
  5883. {0:~ }|
  5884. {0:~ }|
  5885. {0:~ }|
  5886. {0:~ }|
  5887. {0:~ }|
  5888. ## grid 3
  5889. |
  5890. ## grid 4
  5891. {1:^y }|
  5892. {2:~ }|
  5893. ]], float_pos=expected_pos}
  5894. else
  5895. screen:expect([[
  5896. x |
  5897. {0:~ }|
  5898. {0:~ }{1:^y }{0: }|
  5899. {0:~ }{2:~ }{0: }|
  5900. {0:~ }|
  5901. {0:~ }|
  5902. |
  5903. ]])
  5904. end
  5905. feed("<c-w>j")
  5906. if multigrid then
  5907. screen:expect{grid=[[
  5908. ## grid 1
  5909. [2:----------------------------------------]|
  5910. [2:----------------------------------------]|
  5911. [2:----------------------------------------]|
  5912. [2:----------------------------------------]|
  5913. [2:----------------------------------------]|
  5914. [2:----------------------------------------]|
  5915. [3:----------------------------------------]|
  5916. ## grid 2
  5917. ^x |
  5918. {0:~ }|
  5919. {0:~ }|
  5920. {0:~ }|
  5921. {0:~ }|
  5922. {0:~ }|
  5923. ## grid 3
  5924. |
  5925. ## grid 4
  5926. {1:y }|
  5927. {2:~ }|
  5928. ]], float_pos=expected_pos}
  5929. else
  5930. screen:expect([[
  5931. ^x |
  5932. {0:~ }|
  5933. {0:~ }{1:y }{0: }|
  5934. {0:~ }{2:~ }{0: }|
  5935. {0:~ }|
  5936. {0:~ }|
  5937. |
  5938. ]])
  5939. end
  5940. end)
  5941. it("vertical resize + - _", function()
  5942. feed('<c-w>w')
  5943. if multigrid then
  5944. screen:expect{grid=[[
  5945. ## grid 1
  5946. [2:----------------------------------------]|
  5947. [2:----------------------------------------]|
  5948. [2:----------------------------------------]|
  5949. [2:----------------------------------------]|
  5950. [2:----------------------------------------]|
  5951. [2:----------------------------------------]|
  5952. [3:----------------------------------------]|
  5953. ## grid 2
  5954. x |
  5955. {0:~ }|
  5956. {0:~ }|
  5957. {0:~ }|
  5958. {0:~ }|
  5959. {0:~ }|
  5960. ## grid 3
  5961. |
  5962. ## grid 4
  5963. {1:^y }|
  5964. {2:~ }|
  5965. ]], float_pos=expected_pos}
  5966. else
  5967. screen:expect([[
  5968. x |
  5969. {0:~ }|
  5970. {0:~ }{1:^y }{0: }|
  5971. {0:~ }{2:~ }{0: }|
  5972. {0:~ }|
  5973. {0:~ }|
  5974. |
  5975. ]])
  5976. end
  5977. feed('<c-w>+')
  5978. if multigrid then
  5979. screen:expect{grid=[[
  5980. ## grid 1
  5981. [2:----------------------------------------]|
  5982. [2:----------------------------------------]|
  5983. [2:----------------------------------------]|
  5984. [2:----------------------------------------]|
  5985. [2:----------------------------------------]|
  5986. [2:----------------------------------------]|
  5987. [3:----------------------------------------]|
  5988. ## grid 2
  5989. x |
  5990. {0:~ }|
  5991. {0:~ }|
  5992. {0:~ }|
  5993. {0:~ }|
  5994. {0:~ }|
  5995. ## grid 3
  5996. |
  5997. ## grid 4
  5998. {1:^y }|
  5999. {2:~ }|
  6000. {2:~ }|
  6001. ]], float_pos=expected_pos}
  6002. else
  6003. screen:expect([[
  6004. x |
  6005. {0:~ }|
  6006. {0:~ }{1:^y }{0: }|
  6007. {0:~ }{2:~ }{0: }|
  6008. {0:~ }{2:~ }{0: }|
  6009. {0:~ }|
  6010. |
  6011. ]])
  6012. end
  6013. feed('<c-w>2-')
  6014. if multigrid then
  6015. screen:expect{grid=[[
  6016. ## grid 1
  6017. [2:----------------------------------------]|
  6018. [2:----------------------------------------]|
  6019. [2:----------------------------------------]|
  6020. [2:----------------------------------------]|
  6021. [2:----------------------------------------]|
  6022. [2:----------------------------------------]|
  6023. [3:----------------------------------------]|
  6024. ## grid 2
  6025. x |
  6026. {0:~ }|
  6027. {0:~ }|
  6028. {0:~ }|
  6029. {0:~ }|
  6030. {0:~ }|
  6031. ## grid 3
  6032. |
  6033. ## grid 4
  6034. {1:^y }|
  6035. ]], float_pos=expected_pos}
  6036. else
  6037. screen:expect([[
  6038. x |
  6039. {0:~ }|
  6040. {0:~ }{1:^y }{0: }|
  6041. {0:~ }|
  6042. {0:~ }|
  6043. {0:~ }|
  6044. |
  6045. ]])
  6046. end
  6047. feed('<c-w>4_')
  6048. if multigrid then
  6049. screen:expect{grid=[[
  6050. ## grid 1
  6051. [2:----------------------------------------]|
  6052. [2:----------------------------------------]|
  6053. [2:----------------------------------------]|
  6054. [2:----------------------------------------]|
  6055. [2:----------------------------------------]|
  6056. [2:----------------------------------------]|
  6057. [3:----------------------------------------]|
  6058. ## grid 2
  6059. x |
  6060. {0:~ }|
  6061. {0:~ }|
  6062. {0:~ }|
  6063. {0:~ }|
  6064. {0:~ }|
  6065. ## grid 3
  6066. |
  6067. ## grid 4
  6068. {1:^y }|
  6069. {2:~ }|
  6070. {2:~ }|
  6071. {2:~ }|
  6072. ]], float_pos=expected_pos}
  6073. else
  6074. screen:expect([[
  6075. x |
  6076. {0:~ }|
  6077. {0:~ }{1:^y }{0: }|
  6078. {0:~ }{2:~ }{0: }|
  6079. {0:~ }{2:~ }{0: }|
  6080. {0:~ }{2:~ }{0: }|
  6081. |
  6082. ]])
  6083. end
  6084. feed('<c-w>_')
  6085. if multigrid then
  6086. screen:expect{grid=[[
  6087. ## grid 1
  6088. [2:----------------------------------------]|
  6089. [2:----------------------------------------]|
  6090. [2:----------------------------------------]|
  6091. [2:----------------------------------------]|
  6092. [2:----------------------------------------]|
  6093. [2:----------------------------------------]|
  6094. [3:----------------------------------------]|
  6095. ## grid 2
  6096. x |
  6097. {0:~ }|
  6098. {0:~ }|
  6099. {0:~ }|
  6100. {0:~ }|
  6101. {0:~ }|
  6102. ## grid 3
  6103. |
  6104. ## grid 4
  6105. {1:^y }|
  6106. {2:~ }|
  6107. {2:~ }|
  6108. {2:~ }|
  6109. {2:~ }|
  6110. {2:~ }|
  6111. ]], float_pos=expected_pos}
  6112. else
  6113. screen:expect([[
  6114. x {1:^y } |
  6115. {0:~ }{2:~ }{0: }|
  6116. {0:~ }{2:~ }{0: }|
  6117. {0:~ }{2:~ }{0: }|
  6118. {0:~ }{2:~ }{0: }|
  6119. {0:~ }{2:~ }{0: }|
  6120. |
  6121. ]])
  6122. end
  6123. end)
  6124. it("horizontal resize > < |", function()
  6125. feed('<c-w>w')
  6126. if multigrid then
  6127. screen:expect{grid=[[
  6128. ## grid 1
  6129. [2:----------------------------------------]|
  6130. [2:----------------------------------------]|
  6131. [2:----------------------------------------]|
  6132. [2:----------------------------------------]|
  6133. [2:----------------------------------------]|
  6134. [2:----------------------------------------]|
  6135. [3:----------------------------------------]|
  6136. ## grid 2
  6137. x |
  6138. {0:~ }|
  6139. {0:~ }|
  6140. {0:~ }|
  6141. {0:~ }|
  6142. {0:~ }|
  6143. ## grid 3
  6144. |
  6145. ## grid 4
  6146. {1:^y }|
  6147. {2:~ }|
  6148. ]], float_pos=expected_pos}
  6149. else
  6150. screen:expect([[
  6151. x |
  6152. {0:~ }|
  6153. {0:~ }{1:^y }{0: }|
  6154. {0:~ }{2:~ }{0: }|
  6155. {0:~ }|
  6156. {0:~ }|
  6157. |
  6158. ]])
  6159. end
  6160. feed('<c-w>>')
  6161. if multigrid then
  6162. screen:expect{grid=[[
  6163. ## grid 1
  6164. [2:----------------------------------------]|
  6165. [2:----------------------------------------]|
  6166. [2:----------------------------------------]|
  6167. [2:----------------------------------------]|
  6168. [2:----------------------------------------]|
  6169. [2:----------------------------------------]|
  6170. [3:----------------------------------------]|
  6171. ## grid 2
  6172. x |
  6173. {0:~ }|
  6174. {0:~ }|
  6175. {0:~ }|
  6176. {0:~ }|
  6177. {0:~ }|
  6178. ## grid 3
  6179. |
  6180. ## grid 4
  6181. {1:^y }|
  6182. {2:~ }|
  6183. ]], float_pos=expected_pos}
  6184. else
  6185. screen:expect([[
  6186. x |
  6187. {0:~ }|
  6188. {0:~ }{1:^y }{0: }|
  6189. {0:~ }{2:~ }{0: }|
  6190. {0:~ }|
  6191. {0:~ }|
  6192. |
  6193. ]])
  6194. end
  6195. feed('<c-w>10<lt>')
  6196. if multigrid then
  6197. screen:expect{grid=[[
  6198. ## grid 1
  6199. [2:----------------------------------------]|
  6200. [2:----------------------------------------]|
  6201. [2:----------------------------------------]|
  6202. [2:----------------------------------------]|
  6203. [2:----------------------------------------]|
  6204. [2:----------------------------------------]|
  6205. [3:----------------------------------------]|
  6206. ## grid 2
  6207. x |
  6208. {0:~ }|
  6209. {0:~ }|
  6210. {0:~ }|
  6211. {0:~ }|
  6212. {0:~ }|
  6213. ## grid 3
  6214. |
  6215. ## grid 4
  6216. {1:^y }|
  6217. {2:~ }|
  6218. ]], float_pos=expected_pos}
  6219. else
  6220. screen:expect([[
  6221. x |
  6222. {0:~ }|
  6223. {0:~ }{1:^y }{0: }|
  6224. {0:~ }{2:~ }{0: }|
  6225. {0:~ }|
  6226. {0:~ }|
  6227. |
  6228. ]])
  6229. end
  6230. feed('<c-w>15|')
  6231. if multigrid then
  6232. screen:expect{grid=[[
  6233. ## grid 1
  6234. [2:----------------------------------------]|
  6235. [2:----------------------------------------]|
  6236. [2:----------------------------------------]|
  6237. [2:----------------------------------------]|
  6238. [2:----------------------------------------]|
  6239. [2:----------------------------------------]|
  6240. [3:----------------------------------------]|
  6241. ## grid 2
  6242. x |
  6243. {0:~ }|
  6244. {0:~ }|
  6245. {0:~ }|
  6246. {0:~ }|
  6247. {0:~ }|
  6248. ## grid 3
  6249. |
  6250. ## grid 4
  6251. {1:^y }|
  6252. {2:~ }|
  6253. ]], float_pos=expected_pos}
  6254. else
  6255. screen:expect([[
  6256. x |
  6257. {0:~ }|
  6258. {0:~ }{1:^y }{0: }|
  6259. {0:~ }{2:~ }{0: }|
  6260. {0:~ }|
  6261. {0:~ }|
  6262. |
  6263. ]])
  6264. end
  6265. feed('<c-w>|')
  6266. if multigrid then
  6267. screen:expect{grid=[[
  6268. ## grid 1
  6269. [2:----------------------------------------]|
  6270. [2:----------------------------------------]|
  6271. [2:----------------------------------------]|
  6272. [2:----------------------------------------]|
  6273. [2:----------------------------------------]|
  6274. [2:----------------------------------------]|
  6275. [3:----------------------------------------]|
  6276. ## grid 2
  6277. x |
  6278. {0:~ }|
  6279. {0:~ }|
  6280. {0:~ }|
  6281. {0:~ }|
  6282. {0:~ }|
  6283. ## grid 3
  6284. |
  6285. ## grid 4
  6286. {1:^y }|
  6287. {2:~ }|
  6288. ]], float_pos=expected_pos}
  6289. else
  6290. screen:expect([[
  6291. x |
  6292. {0:~ }|
  6293. {1:^y }|
  6294. {2:~ }|
  6295. {0:~ }|
  6296. {0:~ }|
  6297. |
  6298. ]])
  6299. end
  6300. end)
  6301. it("s :split (non-float)", function()
  6302. feed("<c-w>s")
  6303. if multigrid then
  6304. screen:expect{grid=[[
  6305. ## grid 1
  6306. [5:----------------------------------------]|
  6307. [5:----------------------------------------]|
  6308. {4:[No Name] [+] }|
  6309. [2:----------------------------------------]|
  6310. [2:----------------------------------------]|
  6311. {5:[No Name] [+] }|
  6312. [3:----------------------------------------]|
  6313. ## grid 2
  6314. x |
  6315. {0:~ }|
  6316. ## grid 3
  6317. |
  6318. ## grid 4
  6319. {1:y }|
  6320. {2:~ }|
  6321. ## grid 5
  6322. ^x |
  6323. {0:~ }|
  6324. ]], float_pos=expected_pos}
  6325. else
  6326. screen:expect([[
  6327. ^x |
  6328. {0:~ }|
  6329. {4:[No N}{1:y }{4: }|
  6330. x {2:~ } |
  6331. {0:~ }|
  6332. {5:[No Name] [+] }|
  6333. |
  6334. ]])
  6335. end
  6336. feed("<c-w>w")
  6337. if multigrid then
  6338. screen:expect{grid=[[
  6339. ## grid 1
  6340. [5:----------------------------------------]|
  6341. [5:----------------------------------------]|
  6342. {5:[No Name] [+] }|
  6343. [2:----------------------------------------]|
  6344. [2:----------------------------------------]|
  6345. {4:[No Name] [+] }|
  6346. [3:----------------------------------------]|
  6347. ## grid 2
  6348. ^x |
  6349. {0:~ }|
  6350. ## grid 3
  6351. |
  6352. ## grid 4
  6353. {1:y }|
  6354. {2:~ }|
  6355. ## grid 5
  6356. x |
  6357. {0:~ }|
  6358. ]], float_pos=expected_pos}
  6359. else
  6360. screen:expect([[
  6361. x |
  6362. {0:~ }|
  6363. {5:[No N}{1:y }{5: }|
  6364. ^x {2:~ } |
  6365. {0:~ }|
  6366. {4:[No Name] [+] }|
  6367. |
  6368. ]])
  6369. end
  6370. feed("<c-w>w")
  6371. if multigrid then
  6372. screen:expect{grid=[[
  6373. ## grid 1
  6374. [5:----------------------------------------]|
  6375. [5:----------------------------------------]|
  6376. {5:[No Name] [+] }|
  6377. [2:----------------------------------------]|
  6378. [2:----------------------------------------]|
  6379. {5:[No Name] [+] }|
  6380. [3:----------------------------------------]|
  6381. ## grid 2
  6382. x |
  6383. {0:~ }|
  6384. ## grid 3
  6385. |
  6386. ## grid 4
  6387. {1:^y }|
  6388. {2:~ }|
  6389. ## grid 5
  6390. x |
  6391. {0:~ }|
  6392. ]], float_pos=expected_pos}
  6393. else
  6394. screen:expect([[
  6395. x |
  6396. {0:~ }|
  6397. {5:[No N}{1:^y }{5: }|
  6398. x {2:~ } |
  6399. {0:~ }|
  6400. {5:[No Name] [+] }|
  6401. |
  6402. ]])
  6403. end
  6404. feed("<c-w>w")
  6405. if multigrid then
  6406. screen:expect{grid=[[
  6407. ## grid 1
  6408. [5:----------------------------------------]|
  6409. [5:----------------------------------------]|
  6410. {4:[No Name] [+] }|
  6411. [2:----------------------------------------]|
  6412. [2:----------------------------------------]|
  6413. {5:[No Name] [+] }|
  6414. [3:----------------------------------------]|
  6415. ## grid 2
  6416. x |
  6417. {0:~ }|
  6418. ## grid 3
  6419. |
  6420. ## grid 4
  6421. {1:y }|
  6422. {2:~ }|
  6423. ## grid 5
  6424. ^x |
  6425. {0:~ }|
  6426. ]], float_pos=expected_pos}
  6427. else
  6428. screen:expect([[
  6429. ^x |
  6430. {0:~ }|
  6431. {4:[No N}{1:y }{4: }|
  6432. x {2:~ } |
  6433. {0:~ }|
  6434. {5:[No Name] [+] }|
  6435. |
  6436. ]])
  6437. end
  6438. end)
  6439. it("s :split (float)", function()
  6440. feed("<c-w>w<c-w>s")
  6441. if multigrid then
  6442. screen:expect{grid=[[
  6443. ## grid 1
  6444. [5:----------------------------------------]|
  6445. [5:----------------------------------------]|
  6446. {4:[No Name] [+] }|
  6447. [2:----------------------------------------]|
  6448. [2:----------------------------------------]|
  6449. {5:[No Name] [+] }|
  6450. [3:----------------------------------------]|
  6451. ## grid 2
  6452. x |
  6453. {0:~ }|
  6454. ## grid 3
  6455. |
  6456. ## grid 4
  6457. {1:y }|
  6458. {2:~ }|
  6459. ## grid 5
  6460. ^y |
  6461. {0:~ }|
  6462. ]], float_pos=expected_pos}
  6463. else
  6464. screen:expect([[
  6465. ^y |
  6466. {0:~ }|
  6467. {4:[No N}{1:y }{4: }|
  6468. x {2:~ } |
  6469. {0:~ }|
  6470. {5:[No Name] [+] }|
  6471. |
  6472. ]])
  6473. end
  6474. feed("<c-w>j")
  6475. if multigrid then
  6476. screen:expect{grid=[[
  6477. ## grid 1
  6478. [5:----------------------------------------]|
  6479. [5:----------------------------------------]|
  6480. {5:[No Name] [+] }|
  6481. [2:----------------------------------------]|
  6482. [2:----------------------------------------]|
  6483. {4:[No Name] [+] }|
  6484. [3:----------------------------------------]|
  6485. ## grid 2
  6486. ^x |
  6487. {0:~ }|
  6488. ## grid 3
  6489. |
  6490. ## grid 4
  6491. {1:y }|
  6492. {2:~ }|
  6493. ## grid 5
  6494. y |
  6495. {0:~ }|
  6496. ]], float_pos=expected_pos}
  6497. else
  6498. screen:expect([[
  6499. y |
  6500. {0:~ }|
  6501. {5:[No N}{1:y }{5: }|
  6502. ^x {2:~ } |
  6503. {0:~ }|
  6504. {4:[No Name] [+] }|
  6505. |
  6506. ]])
  6507. end
  6508. feed("<c-w>ji")
  6509. if multigrid then
  6510. screen:expect{grid=[[
  6511. ## grid 1
  6512. [5:----------------------------------------]|
  6513. [5:----------------------------------------]|
  6514. {5:[No Name] [+] }|
  6515. [2:----------------------------------------]|
  6516. [2:----------------------------------------]|
  6517. {4:[No Name] [+] }|
  6518. [3:----------------------------------------]|
  6519. ## grid 2
  6520. ^x |
  6521. {0:~ }|
  6522. ## grid 3
  6523. {3:-- INSERT --} |
  6524. ## grid 4
  6525. {1:y }|
  6526. {2:~ }|
  6527. ## grid 5
  6528. y |
  6529. {0:~ }|
  6530. ]], float_pos=expected_pos}
  6531. else
  6532. screen:expect([[
  6533. y |
  6534. {0:~ }|
  6535. {5:[No N}{1:y }{5: }|
  6536. ^x {2:~ } |
  6537. {0:~ }|
  6538. {4:[No Name] [+] }|
  6539. {3:-- INSERT --} |
  6540. ]])
  6541. end
  6542. end)
  6543. it(":new (non-float)", function()
  6544. feed(":new<cr>")
  6545. if multigrid then
  6546. screen:expect{grid=[[
  6547. ## grid 1
  6548. [5:----------------------------------------]|
  6549. [5:----------------------------------------]|
  6550. {4:[No Name] }|
  6551. [2:----------------------------------------]|
  6552. [2:----------------------------------------]|
  6553. {5:[No Name] [+] }|
  6554. [3:----------------------------------------]|
  6555. ## grid 2
  6556. x |
  6557. {0:~ }|
  6558. ## grid 3
  6559. :new |
  6560. ## grid 4
  6561. {1:y }|
  6562. {2:~ }|
  6563. ## grid 5
  6564. ^ |
  6565. {0:~ }|
  6566. ]], float_pos=expected_pos}
  6567. else
  6568. screen:expect([[
  6569. ^ |
  6570. {0:~ }|
  6571. {4:[No N}{1:y }{4: }|
  6572. x {2:~ } |
  6573. {0:~ }|
  6574. {5:[No Name] [+] }|
  6575. :new |
  6576. ]])
  6577. end
  6578. end)
  6579. it(":new (float)", function()
  6580. feed("<c-w>w:new<cr>")
  6581. if multigrid then
  6582. screen:expect{grid=[[
  6583. ## grid 1
  6584. [5:----------------------------------------]|
  6585. [5:----------------------------------------]|
  6586. {4:[No Name] }|
  6587. [2:----------------------------------------]|
  6588. [2:----------------------------------------]|
  6589. {5:[No Name] [+] }|
  6590. [3:----------------------------------------]|
  6591. ## grid 2
  6592. x |
  6593. {0:~ }|
  6594. ## grid 3
  6595. :new |
  6596. ## grid 4
  6597. {1:y }|
  6598. {2:~ }|
  6599. ## grid 5
  6600. ^ |
  6601. {0:~ }|
  6602. ]], float_pos=expected_pos}
  6603. else
  6604. screen:expect([[
  6605. ^ |
  6606. {0:~ }|
  6607. {4:[No N}{1:y }{4: }|
  6608. x {2:~ } |
  6609. {0:~ }|
  6610. {5:[No Name] [+] }|
  6611. :new |
  6612. ]])
  6613. end
  6614. end)
  6615. it("v :vsplit (non-float)", function()
  6616. feed("<c-w>v")
  6617. if multigrid then
  6618. screen:expect{grid=[[
  6619. ## grid 1
  6620. [5:--------------------]{5:│}[2:-------------------]|
  6621. [5:--------------------]{5:│}[2:-------------------]|
  6622. [5:--------------------]{5:│}[2:-------------------]|
  6623. [5:--------------------]{5:│}[2:-------------------]|
  6624. [5:--------------------]{5:│}[2:-------------------]|
  6625. {4:[No Name] [+] }{5:[No Name] [+] }|
  6626. [3:----------------------------------------]|
  6627. ## grid 2
  6628. x |
  6629. {0:~ }|
  6630. {0:~ }|
  6631. {0:~ }|
  6632. {0:~ }|
  6633. ## grid 3
  6634. |
  6635. ## grid 4
  6636. {1:y }|
  6637. {2:~ }|
  6638. ## grid 5
  6639. ^x |
  6640. {0:~ }|
  6641. {0:~ }|
  6642. {0:~ }|
  6643. {0:~ }|
  6644. ]], float_pos=expected_pos}
  6645. else
  6646. screen:expect([[
  6647. ^x {5:│}x |
  6648. {0:~ }{5:│}{0:~ }|
  6649. {0:~ }{1:y }{0: }|
  6650. {0:~ }{2:~ }{0: }|
  6651. {0:~ }{5:│}{0:~ }|
  6652. {4:[No Name] [+] }{5:[No Name] [+] }|
  6653. |
  6654. ]])
  6655. end
  6656. end)
  6657. it(":vnew (non-float)", function()
  6658. feed(":vnew<cr>")
  6659. if multigrid then
  6660. screen:expect{grid=[[
  6661. ## grid 1
  6662. [5:--------------------]{5:│}[2:-------------------]|
  6663. [5:--------------------]{5:│}[2:-------------------]|
  6664. [5:--------------------]{5:│}[2:-------------------]|
  6665. [5:--------------------]{5:│}[2:-------------------]|
  6666. [5:--------------------]{5:│}[2:-------------------]|
  6667. {4:[No Name] }{5:[No Name] [+] }|
  6668. [3:----------------------------------------]|
  6669. ## grid 2
  6670. x |
  6671. {0:~ }|
  6672. {0:~ }|
  6673. {0:~ }|
  6674. {0:~ }|
  6675. ## grid 3
  6676. :vnew |
  6677. ## grid 4
  6678. {1:y }|
  6679. {2:~ }|
  6680. ## grid 5
  6681. ^ |
  6682. {0:~ }|
  6683. {0:~ }|
  6684. {0:~ }|
  6685. {0:~ }|
  6686. ]], float_pos=expected_pos}
  6687. else
  6688. screen:expect([[
  6689. ^ {5:│}x |
  6690. {0:~ }{5:│}{0:~ }|
  6691. {0:~ }{1:y }{0: }|
  6692. {0:~ }{2:~ }{0: }|
  6693. {0:~ }{5:│}{0:~ }|
  6694. {4:[No Name] }{5:[No Name] [+] }|
  6695. :vnew |
  6696. ]])
  6697. end
  6698. end)
  6699. it(":vnew (float)", function()
  6700. feed("<c-w>w:vnew<cr>")
  6701. if multigrid then
  6702. screen:expect{grid=[[
  6703. ## grid 1
  6704. [5:--------------------]{5:│}[2:-------------------]|
  6705. [5:--------------------]{5:│}[2:-------------------]|
  6706. [5:--------------------]{5:│}[2:-------------------]|
  6707. [5:--------------------]{5:│}[2:-------------------]|
  6708. [5:--------------------]{5:│}[2:-------------------]|
  6709. {4:[No Name] }{5:[No Name] [+] }|
  6710. [3:----------------------------------------]|
  6711. ## grid 2
  6712. x |
  6713. {0:~ }|
  6714. {0:~ }|
  6715. {0:~ }|
  6716. {0:~ }|
  6717. ## grid 3
  6718. :vnew |
  6719. ## grid 4
  6720. {1:y }|
  6721. {2:~ }|
  6722. ## grid 5
  6723. ^ |
  6724. {0:~ }|
  6725. {0:~ }|
  6726. {0:~ }|
  6727. {0:~ }|
  6728. ]], float_pos=expected_pos}
  6729. else
  6730. screen:expect([[
  6731. ^ {5:│}x |
  6732. {0:~ }{5:│}{0:~ }|
  6733. {0:~ }{1:y }{0: }|
  6734. {0:~ }{2:~ }{0: }|
  6735. {0:~ }{5:│}{0:~ }|
  6736. {4:[No Name] }{5:[No Name] [+] }|
  6737. :vnew |
  6738. ]])
  6739. end
  6740. end)
  6741. it("q (:quit) last non-float exits nvim", function()
  6742. command('autocmd VimLeave * call rpcrequest(1, "exit")')
  6743. -- avoid unsaved change in other buffer
  6744. feed("<c-w><c-w>:w Xtest_written2<cr><c-w><c-w>")
  6745. -- quit in last non-float
  6746. feed(":wq Xtest_written<cr>")
  6747. local exited = false
  6748. local function on_request(name, args)
  6749. eq("exit", name)
  6750. eq({}, args)
  6751. exited = true
  6752. return 0
  6753. end
  6754. local function on_setup()
  6755. feed(":wq Xtest_written<cr>")
  6756. end
  6757. run(on_request, nil, on_setup)
  6758. os.remove('Xtest_written')
  6759. os.remove('Xtest_written2')
  6760. eq(exited, true)
  6761. end)
  6762. it(':quit two floats in a row', function()
  6763. -- enter first float
  6764. feed('<c-w><c-w>')
  6765. -- enter second float
  6766. meths.open_win(0, true, {relative='editor', width=20, height=2, row=4, col=8})
  6767. if multigrid then
  6768. screen:expect{grid=[[
  6769. ## grid 1
  6770. [2:----------------------------------------]|
  6771. [2:----------------------------------------]|
  6772. [2:----------------------------------------]|
  6773. [2:----------------------------------------]|
  6774. [2:----------------------------------------]|
  6775. [2:----------------------------------------]|
  6776. [3:----------------------------------------]|
  6777. ## grid 2
  6778. x |
  6779. {0:~ }|
  6780. {0:~ }|
  6781. {0:~ }|
  6782. {0:~ }|
  6783. {0:~ }|
  6784. ## grid 3
  6785. |
  6786. ## grid 4
  6787. {1:y }|
  6788. {2:~ }|
  6789. ## grid 5
  6790. {1:^y }|
  6791. {2:~ }|
  6792. ]], float_pos={
  6793. [4] = {{id = 1001}, "NW", 1, 2, 5, true},
  6794. [5] = {{id = 1002}, "NW", 1, 4, 8, true}
  6795. }}
  6796. else
  6797. screen:expect([[
  6798. x |
  6799. {0:~ }|
  6800. {0:~ }{1:y }{0: }|
  6801. {0:~ }{2:~ }{0: }|
  6802. {0:~ }{1:^y }{0: }|
  6803. {0:~ }{2:~ }{0: }|
  6804. |
  6805. ]])
  6806. end
  6807. feed(':quit<cr>')
  6808. if multigrid then
  6809. screen:expect{grid=[[
  6810. ## grid 1
  6811. [2:----------------------------------------]|
  6812. [2:----------------------------------------]|
  6813. [2:----------------------------------------]|
  6814. [2:----------------------------------------]|
  6815. [2:----------------------------------------]|
  6816. [2:----------------------------------------]|
  6817. [3:----------------------------------------]|
  6818. ## grid 2
  6819. x |
  6820. {0:~ }|
  6821. {0:~ }|
  6822. {0:~ }|
  6823. {0:~ }|
  6824. {0:~ }|
  6825. ## grid 3
  6826. :quit |
  6827. ## grid 4
  6828. {1:^y }|
  6829. {2:~ }|
  6830. ]], float_pos={
  6831. [4] = {{id = 1001}, "NW", 1, 2, 5, true},
  6832. }}
  6833. else
  6834. screen:expect([[
  6835. x |
  6836. {0:~ }|
  6837. {0:~ }{1:^y }{0: }|
  6838. {0:~ }{2:~ }{0: }|
  6839. {0:~ }|
  6840. {0:~ }|
  6841. :quit |
  6842. ]])
  6843. end
  6844. feed(':quit<cr>')
  6845. if multigrid then
  6846. screen:expect([[
  6847. ## grid 1
  6848. [2:----------------------------------------]|
  6849. [2:----------------------------------------]|
  6850. [2:----------------------------------------]|
  6851. [2:----------------------------------------]|
  6852. [2:----------------------------------------]|
  6853. [2:----------------------------------------]|
  6854. [3:----------------------------------------]|
  6855. ## grid 2
  6856. ^x |
  6857. {0:~ }|
  6858. {0:~ }|
  6859. {0:~ }|
  6860. {0:~ }|
  6861. {0:~ }|
  6862. ## grid 3
  6863. :quit |
  6864. ]])
  6865. else
  6866. screen:expect([[
  6867. ^x |
  6868. {0:~ }|
  6869. {0:~ }|
  6870. {0:~ }|
  6871. {0:~ }|
  6872. {0:~ }|
  6873. :quit |
  6874. ]])
  6875. end
  6876. assert_alive()
  6877. end)
  6878. it("o (:only) non-float", function()
  6879. feed("<c-w>o")
  6880. if multigrid then
  6881. screen:expect{grid=[[
  6882. ## grid 1
  6883. [2:----------------------------------------]|
  6884. [2:----------------------------------------]|
  6885. [2:----------------------------------------]|
  6886. [2:----------------------------------------]|
  6887. [2:----------------------------------------]|
  6888. [2:----------------------------------------]|
  6889. [3:----------------------------------------]|
  6890. ## grid 2
  6891. ^x |
  6892. {0:~ }|
  6893. {0:~ }|
  6894. {0:~ }|
  6895. {0:~ }|
  6896. {0:~ }|
  6897. ## grid 3
  6898. |
  6899. ]]}
  6900. else
  6901. screen:expect([[
  6902. ^x |
  6903. {0:~ }|
  6904. {0:~ }|
  6905. {0:~ }|
  6906. {0:~ }|
  6907. {0:~ }|
  6908. |
  6909. ]])
  6910. end
  6911. end)
  6912. it("o (:only) float fails", function()
  6913. feed("<c-w>w<c-w>o")
  6914. if multigrid then
  6915. screen:expect{grid=[[
  6916. ## grid 1
  6917. [2:----------------------------------------]|
  6918. [2:----------------------------------------]|
  6919. [2:----------------------------------------]|
  6920. [2:----------------------------------------]|
  6921. [3:----------------------------------------]|
  6922. [3:----------------------------------------]|
  6923. [3:----------------------------------------]|
  6924. ## grid 2
  6925. x |
  6926. {0:~ }|
  6927. {0:~ }|
  6928. {0:~ }|
  6929. {0:~ }|
  6930. {0:~ }|
  6931. ## grid 3
  6932. {7:E5601: Cannot close window, only floatin}|
  6933. {7:g window would remain} |
  6934. {8:Press ENTER or type command to continue}^ |
  6935. ## grid 4
  6936. {1:y }|
  6937. {2:~ }|
  6938. ]], float_pos=expected_pos}
  6939. else
  6940. screen:expect([[
  6941. x |
  6942. {0:~ }|
  6943. {0:~ }{1:y }{0: }|
  6944. {4: }|
  6945. {7:E5601: Cannot close window, only floatin}|
  6946. {7:g window would remain} |
  6947. {8:Press ENTER or type command to continue}^ |
  6948. ]])
  6949. end
  6950. -- test message clear
  6951. feed('<cr>')
  6952. if multigrid then
  6953. screen:expect{grid=[[
  6954. ## grid 1
  6955. [2:----------------------------------------]|
  6956. [2:----------------------------------------]|
  6957. [2:----------------------------------------]|
  6958. [2:----------------------------------------]|
  6959. [2:----------------------------------------]|
  6960. [2:----------------------------------------]|
  6961. [3:----------------------------------------]|
  6962. ## grid 2
  6963. x |
  6964. {0:~ }|
  6965. {0:~ }|
  6966. {0:~ }|
  6967. {0:~ }|
  6968. {0:~ }|
  6969. ## grid 3
  6970. |
  6971. ## grid 4
  6972. {1:^y }|
  6973. {2:~ }|
  6974. ]], float_pos=expected_pos}
  6975. else
  6976. screen:expect([[
  6977. x |
  6978. {0:~ }|
  6979. {0:~ }{1:^y }{0: }|
  6980. {0:~ }{2:~ }{0: }|
  6981. {0:~ }|
  6982. {0:~ }|
  6983. |
  6984. ]])
  6985. end
  6986. end)
  6987. it("o (:only) non-float with split", function()
  6988. feed("<c-w>s")
  6989. if multigrid then
  6990. screen:expect{grid=[[
  6991. ## grid 1
  6992. [5:----------------------------------------]|
  6993. [5:----------------------------------------]|
  6994. {4:[No Name] [+] }|
  6995. [2:----------------------------------------]|
  6996. [2:----------------------------------------]|
  6997. {5:[No Name] [+] }|
  6998. [3:----------------------------------------]|
  6999. ## grid 2
  7000. x |
  7001. {0:~ }|
  7002. ## grid 3
  7003. |
  7004. ## grid 4
  7005. {1:y }|
  7006. {2:~ }|
  7007. ## grid 5
  7008. ^x |
  7009. {0:~ }|
  7010. ]], float_pos=expected_pos}
  7011. else
  7012. screen:expect([[
  7013. ^x |
  7014. {0:~ }|
  7015. {4:[No N}{1:y }{4: }|
  7016. x {2:~ } |
  7017. {0:~ }|
  7018. {5:[No Name] [+] }|
  7019. |
  7020. ]])
  7021. end
  7022. feed("<c-w>o")
  7023. if multigrid then
  7024. screen:expect{grid=[[
  7025. ## grid 1
  7026. [5:----------------------------------------]|
  7027. [5:----------------------------------------]|
  7028. [5:----------------------------------------]|
  7029. [5:----------------------------------------]|
  7030. [5:----------------------------------------]|
  7031. [5:----------------------------------------]|
  7032. [3:----------------------------------------]|
  7033. ## grid 3
  7034. |
  7035. ## grid 5
  7036. ^x |
  7037. {0:~ }|
  7038. {0:~ }|
  7039. {0:~ }|
  7040. {0:~ }|
  7041. {0:~ }|
  7042. ]]}
  7043. else
  7044. screen:expect([[
  7045. ^x |
  7046. {0:~ }|
  7047. {0:~ }|
  7048. {0:~ }|
  7049. {0:~ }|
  7050. {0:~ }|
  7051. |
  7052. ]])
  7053. end
  7054. end)
  7055. it("o (:only) float with split", function()
  7056. feed("<c-w>s<c-w>W")
  7057. if multigrid then
  7058. screen:expect{grid=[[
  7059. ## grid 1
  7060. [5:----------------------------------------]|
  7061. [5:----------------------------------------]|
  7062. {5:[No Name] [+] }|
  7063. [2:----------------------------------------]|
  7064. [2:----------------------------------------]|
  7065. {5:[No Name] [+] }|
  7066. [3:----------------------------------------]|
  7067. ## grid 2
  7068. x |
  7069. {0:~ }|
  7070. ## grid 3
  7071. |
  7072. ## grid 4
  7073. {1:^y }|
  7074. {2:~ }|
  7075. ## grid 5
  7076. x |
  7077. {0:~ }|
  7078. ]], float_pos=expected_pos}
  7079. else
  7080. screen:expect([[
  7081. x |
  7082. {0:~ }|
  7083. {5:[No N}{1:^y }{5: }|
  7084. x {2:~ } |
  7085. {0:~ }|
  7086. {5:[No Name] [+] }|
  7087. |
  7088. ]])
  7089. end
  7090. feed("<c-w>o")
  7091. if multigrid then
  7092. screen:expect{grid=[[
  7093. ## grid 1
  7094. [5:----------------------------------------]|
  7095. [5:----------------------------------------]|
  7096. {5:[No Name] [+] }|
  7097. [2:----------------------------------------]|
  7098. [3:----------------------------------------]|
  7099. [3:----------------------------------------]|
  7100. [3:----------------------------------------]|
  7101. ## grid 2
  7102. x |
  7103. {0:~ }|
  7104. ## grid 3
  7105. {7:E5601: Cannot close window, only floatin}|
  7106. {7:g window would remain} |
  7107. {8:Press ENTER or type command to continue}^ |
  7108. ## grid 4
  7109. {1:y }|
  7110. {2:~ }|
  7111. ## grid 5
  7112. x |
  7113. {0:~ }|
  7114. ]], float_pos=expected_pos}
  7115. else
  7116. screen:expect([[
  7117. x |
  7118. {0:~ }|
  7119. {5:[No N}{1:y }{5: }|
  7120. {4: }|
  7121. {7:E5601: Cannot close window, only floatin}|
  7122. {7:g window would remain} |
  7123. {8:Press ENTER or type command to continue}^ |
  7124. ]])
  7125. end
  7126. end)
  7127. it("J (float)", function()
  7128. feed("<c-w>w<c-w>J")
  7129. if multigrid then
  7130. screen:expect{grid=[[
  7131. ## grid 1
  7132. [2:----------------------------------------]|
  7133. [2:----------------------------------------]|
  7134. {5:[No Name] [+] }|
  7135. [4:----------------------------------------]|
  7136. [4:----------------------------------------]|
  7137. {4:[No Name] [+] }|
  7138. [3:----------------------------------------]|
  7139. ## grid 2
  7140. x |
  7141. {0:~ }|
  7142. ## grid 3
  7143. |
  7144. ## grid 4
  7145. ^y |
  7146. {0:~ }|
  7147. ]]}
  7148. else
  7149. screen:expect([[
  7150. x |
  7151. {0:~ }|
  7152. {5:[No Name] [+] }|
  7153. ^y |
  7154. {0:~ }|
  7155. {4:[No Name] [+] }|
  7156. |
  7157. ]])
  7158. end
  7159. if multigrid then
  7160. meths.win_set_config(0, {external=true, width=30, height=2})
  7161. expected_pos = {[4]={external=true}}
  7162. screen:expect{grid=[[
  7163. ## grid 1
  7164. [2:----------------------------------------]|
  7165. [2:----------------------------------------]|
  7166. [2:----------------------------------------]|
  7167. [2:----------------------------------------]|
  7168. [2:----------------------------------------]|
  7169. {5:[No Name] [+] }|
  7170. [3:----------------------------------------]|
  7171. ## grid 2
  7172. x |
  7173. {0:~ }|
  7174. {0:~ }|
  7175. {0:~ }|
  7176. {0:~ }|
  7177. ## grid 3
  7178. |
  7179. ## grid 4
  7180. ^y |
  7181. {0:~ }|
  7182. ]], float_pos=expected_pos}
  7183. else
  7184. eq("UI doesn't support external windows",
  7185. pcall_err(meths.win_set_config, 0, {external=true, width=30, height=2}))
  7186. return
  7187. end
  7188. feed("<c-w>J")
  7189. if multigrid then
  7190. screen:expect([[
  7191. ## grid 1
  7192. [2:----------------------------------------]|
  7193. [2:----------------------------------------]|
  7194. {5:[No Name] [+] }|
  7195. [4:----------------------------------------]|
  7196. [4:----------------------------------------]|
  7197. {4:[No Name] [+] }|
  7198. [3:----------------------------------------]|
  7199. ## grid 2
  7200. x |
  7201. {0:~ }|
  7202. ## grid 3
  7203. |
  7204. ## grid 4
  7205. ^y |
  7206. {0:~ }|
  7207. ]])
  7208. end
  7209. end)
  7210. it('J (float with border)', function()
  7211. meths.win_set_config(win, {relative='editor', width=20, height=2, row=2, col=5, border='single'})
  7212. if multigrid then
  7213. screen:expect{grid=[[
  7214. ## grid 1
  7215. [2:----------------------------------------]|
  7216. [2:----------------------------------------]|
  7217. [2:----------------------------------------]|
  7218. [2:----------------------------------------]|
  7219. [2:----------------------------------------]|
  7220. [2:----------------------------------------]|
  7221. [3:----------------------------------------]|
  7222. ## grid 2
  7223. ^x |
  7224. {0:~ }|
  7225. {0:~ }|
  7226. {0:~ }|
  7227. {0:~ }|
  7228. {0:~ }|
  7229. ## grid 3
  7230. |
  7231. ## grid 4
  7232. {5:┌────────────────────┐}|
  7233. {5:│}{1:y }{5:│}|
  7234. {5:│}{2:~ }{5:│}|
  7235. {5:└────────────────────┘}|
  7236. ]], float_pos=expected_pos}
  7237. else
  7238. screen:expect([[
  7239. ^x |
  7240. {0:~ }|
  7241. {0:~ }{5:┌────────────────────┐}{0: }|
  7242. {0:~ }{5:│}{1:y }{5:│}{0: }|
  7243. {0:~ }{5:│}{2:~ }{5:│}{0: }|
  7244. {0:~ }{5:└────────────────────┘}{0: }|
  7245. |
  7246. ]])
  7247. end
  7248. feed("<c-w>w<c-w>J")
  7249. if multigrid then
  7250. screen:expect{grid=[[
  7251. ## grid 1
  7252. [2:----------------------------------------]|
  7253. [2:----------------------------------------]|
  7254. {5:[No Name] [+] }|
  7255. [4:----------------------------------------]|
  7256. [4:----------------------------------------]|
  7257. {4:[No Name] [+] }|
  7258. [3:----------------------------------------]|
  7259. ## grid 2
  7260. x |
  7261. {0:~ }|
  7262. ## grid 3
  7263. |
  7264. ## grid 4
  7265. ^y |
  7266. {0:~ }|
  7267. ]]}
  7268. else
  7269. screen:expect([[
  7270. x |
  7271. {0:~ }|
  7272. {5:[No Name] [+] }|
  7273. ^y |
  7274. {0:~ }|
  7275. {4:[No Name] [+] }|
  7276. |
  7277. ]])
  7278. end
  7279. end)
  7280. it('movements with nested split layout', function()
  7281. command("set hidden")
  7282. feed("<c-w>s<c-w>v<c-w>b<c-w>v")
  7283. if multigrid then
  7284. screen:expect{grid=[[
  7285. ## grid 1
  7286. [6:--------------------]{5:│}[5:-------------------]|
  7287. [6:--------------------]{5:│}[5:-------------------]|
  7288. {5:[No Name] [+] [No Name] [+] }|
  7289. [7:--------------------]{5:│}[2:-------------------]|
  7290. [7:--------------------]{5:│}[2:-------------------]|
  7291. {4:[No Name] [+] }{5:[No Name] [+] }|
  7292. [3:----------------------------------------]|
  7293. ## grid 2
  7294. x |
  7295. {0:~ }|
  7296. ## grid 3
  7297. |
  7298. ## grid 4
  7299. {1:y }|
  7300. {2:~ }|
  7301. ## grid 5
  7302. x |
  7303. {0:~ }|
  7304. ## grid 6
  7305. x |
  7306. {0:~ }|
  7307. ## grid 7
  7308. ^x |
  7309. {0:~ }|
  7310. ]], float_pos=expected_pos}
  7311. else
  7312. screen:expect([[
  7313. x {5:│}x |
  7314. {0:~ }{5:│}{0:~ }|
  7315. {5:[No N}{1:y }{5:Name] [+] }|
  7316. ^x {2:~ } |
  7317. {0:~ }{5:│}{0:~ }|
  7318. {4:[No Name] [+] }{5:[No Name] [+] }|
  7319. |
  7320. ]])
  7321. end
  7322. -- verify that N<c-w>w works
  7323. for i = 1,5 do
  7324. feed(i.."<c-w>w")
  7325. feed_command("enew")
  7326. curbufmeths.set_lines(0,-1,true,{tostring(i)})
  7327. end
  7328. if multigrid then
  7329. screen:expect{grid=[[
  7330. ## grid 1
  7331. [6:-------------------]{5:│}[5:--------------------]|
  7332. [6:-------------------]{5:│}[5:--------------------]|
  7333. {5:[No Name] [+] [No Name] [+] }|
  7334. [7:-------------------]{5:│}[2:--------------------]|
  7335. [7:-------------------]{5:│}[2:--------------------]|
  7336. {5:[No Name] [+] [No Name] [+] }|
  7337. [3:----------------------------------------]|
  7338. ## grid 2
  7339. 4 |
  7340. {0:~ }|
  7341. ## grid 3
  7342. :enew |
  7343. ## grid 4
  7344. {1:^5 }|
  7345. {2:~ }|
  7346. ## grid 5
  7347. 2 |
  7348. {0:~ }|
  7349. ## grid 6
  7350. 1 |
  7351. {0:~ }|
  7352. ## grid 7
  7353. 3 |
  7354. {0:~ }|
  7355. ]], float_pos=expected_pos}
  7356. else
  7357. screen:expect([[
  7358. 1 {5:│}2 |
  7359. {0:~ }{5:│}{0:~ }|
  7360. {5:[No N}{1:^5 }{5:ame] [+] }|
  7361. 3 {2:~ } |
  7362. {0:~ }{5:│}{0:~ }|
  7363. {5:[No Name] [+] [No Name] [+] }|
  7364. :enew |
  7365. ]])
  7366. end
  7367. local movements = {
  7368. w={2,3,4,5,1},
  7369. W={5,1,2,3,4},
  7370. h={1,1,3,3,3},
  7371. j={3,3,3,4,4},
  7372. k={1,2,1,1,1},
  7373. l={2,2,4,4,4},
  7374. t={1,1,1,1,1},
  7375. b={4,4,4,4,4},
  7376. }
  7377. for k,v in pairs(movements) do
  7378. for i = 1,5 do
  7379. feed(i.."<c-w>w")
  7380. feed('<c-w>'..k)
  7381. local nr = funcs.winnr()
  7382. eq(v[i],nr, "when using <c-w>"..k.." from window "..i)
  7383. end
  7384. end
  7385. for i = 1,5 do
  7386. feed(i.."<c-w>w")
  7387. for j = 1,5 do
  7388. if j ~= i then
  7389. feed(j.."<c-w>w")
  7390. feed('<c-w>p')
  7391. local nr = funcs.winnr()
  7392. eq(i,nr, "when using <c-w>p to window "..i.." from window "..j)
  7393. end
  7394. end
  7395. end
  7396. end)
  7397. it(":tabnew and :tabnext", function()
  7398. feed(":tabnew<cr>")
  7399. if multigrid then
  7400. -- grid is not freed, but float is marked as closed (should it rather be "invisible"?)
  7401. screen:expect{grid=[[
  7402. ## grid 1
  7403. {9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}|
  7404. [5:----------------------------------------]|
  7405. [5:----------------------------------------]|
  7406. [5:----------------------------------------]|
  7407. [5:----------------------------------------]|
  7408. [5:----------------------------------------]|
  7409. [3:----------------------------------------]|
  7410. ## grid 2 (hidden)
  7411. x |
  7412. {0:~ }|
  7413. {0:~ }|
  7414. {0:~ }|
  7415. {0:~ }|
  7416. {0:~ }|
  7417. ## grid 3
  7418. :tabnew |
  7419. ## grid 4 (hidden)
  7420. {1:y }|
  7421. {2:~ }|
  7422. ## grid 5
  7423. ^ |
  7424. {0:~ }|
  7425. {0:~ }|
  7426. {0:~ }|
  7427. {0:~ }|
  7428. ]]}
  7429. else
  7430. screen:expect([[
  7431. {9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}|
  7432. ^ |
  7433. {0:~ }|
  7434. {0:~ }|
  7435. {0:~ }|
  7436. {0:~ }|
  7437. :tabnew |
  7438. ]])
  7439. end
  7440. feed(":tabnext<cr>")
  7441. if multigrid then
  7442. screen:expect{grid=[[
  7443. ## grid 1
  7444. {3: }{11:2}{3:+ [No Name] }{9: [No Name] }{5: }{9:X}|
  7445. [2:----------------------------------------]|
  7446. [2:----------------------------------------]|
  7447. [2:----------------------------------------]|
  7448. [2:----------------------------------------]|
  7449. [2:----------------------------------------]|
  7450. [3:----------------------------------------]|
  7451. ## grid 2
  7452. ^x |
  7453. {0:~ }|
  7454. {0:~ }|
  7455. {0:~ }|
  7456. {0:~ }|
  7457. ## grid 3
  7458. :tabnext |
  7459. ## grid 4
  7460. {1:y }|
  7461. {2:~ }|
  7462. ## grid 5 (hidden)
  7463. |
  7464. {0:~ }|
  7465. {0:~ }|
  7466. {0:~ }|
  7467. {0:~ }|
  7468. ]], float_pos=expected_pos}
  7469. else
  7470. screen:expect([[
  7471. {3: }{11:2}{3:+ [No Name] }{9: [No Name] }{5: }{9:X}|
  7472. ^x |
  7473. {0:~ }{1:y }{0: }|
  7474. {0:~ }{2:~ }{0: }|
  7475. {0:~ }|
  7476. {0:~ }|
  7477. :tabnext |
  7478. ]])
  7479. end
  7480. feed(":tabnext<cr>")
  7481. if multigrid then
  7482. screen:expect{grid=[[
  7483. ## grid 1
  7484. {9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}|
  7485. [5:----------------------------------------]|
  7486. [5:----------------------------------------]|
  7487. [5:----------------------------------------]|
  7488. [5:----------------------------------------]|
  7489. [5:----------------------------------------]|
  7490. [3:----------------------------------------]|
  7491. ## grid 2 (hidden)
  7492. x |
  7493. {0:~ }|
  7494. {0:~ }|
  7495. {0:~ }|
  7496. {0:~ }|
  7497. ## grid 3
  7498. :tabnext |
  7499. ## grid 4 (hidden)
  7500. {1:y }|
  7501. {2:~ }|
  7502. ## grid 5
  7503. ^ |
  7504. {0:~ }|
  7505. {0:~ }|
  7506. {0:~ }|
  7507. {0:~ }|
  7508. ]]}
  7509. else
  7510. screen:expect([[
  7511. {9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}|
  7512. ^ |
  7513. {0:~ }|
  7514. {0:~ }|
  7515. {0:~ }|
  7516. {0:~ }|
  7517. :tabnext |
  7518. ]])
  7519. end
  7520. end)
  7521. it(":tabnew and :tabnext (external)", function()
  7522. if multigrid then
  7523. -- also test external window wider than main screen
  7524. meths.win_set_config(win, {external=true, width=65, height=4})
  7525. expected_pos = {[4]={external=true}}
  7526. feed(":tabnew<cr>")
  7527. screen:expect{grid=[[
  7528. ## grid 1
  7529. {9: + [No Name] }{3: }{11:2}{3:+ [No Name] }{5: }{9:X}|
  7530. [5:----------------------------------------]|
  7531. [5:----------------------------------------]|
  7532. [5:----------------------------------------]|
  7533. [5:----------------------------------------]|
  7534. [5:----------------------------------------]|
  7535. [3:----------------------------------------]|
  7536. ## grid 2 (hidden)
  7537. x |
  7538. {0:~ }|
  7539. {0:~ }|
  7540. {0:~ }|
  7541. {0:~ }|
  7542. {0:~ }|
  7543. ## grid 3
  7544. :tabnew |
  7545. ## grid 4
  7546. y |
  7547. {0:~ }|
  7548. {0:~ }|
  7549. {0:~ }|
  7550. ## grid 5
  7551. ^ |
  7552. {0:~ }|
  7553. {0:~ }|
  7554. {0:~ }|
  7555. {0:~ }|
  7556. ]], float_pos=expected_pos}
  7557. else
  7558. eq("UI doesn't support external windows",
  7559. pcall_err(meths.win_set_config, 0, {external=true, width=65, height=4}))
  7560. end
  7561. feed(":tabnext<cr>")
  7562. if multigrid then
  7563. screen:expect{grid=[[
  7564. ## grid 1
  7565. {3: }{11:2}{3:+ [No Name] }{9: [No Name] }{5: }{9:X}|
  7566. [2:----------------------------------------]|
  7567. [2:----------------------------------------]|
  7568. [2:----------------------------------------]|
  7569. [2:----------------------------------------]|
  7570. [2:----------------------------------------]|
  7571. [3:----------------------------------------]|
  7572. ## grid 2
  7573. ^x |
  7574. {0:~ }|
  7575. {0:~ }|
  7576. {0:~ }|
  7577. {0:~ }|
  7578. ## grid 3
  7579. :tabnext |
  7580. ## grid 4
  7581. y |
  7582. {0:~ }|
  7583. {0:~ }|
  7584. {0:~ }|
  7585. ## grid 5 (hidden)
  7586. |
  7587. {0:~ }|
  7588. {0:~ }|
  7589. {0:~ }|
  7590. {0:~ }|
  7591. ]], float_pos=expected_pos}
  7592. end
  7593. feed(":tabnext<cr>")
  7594. if multigrid then
  7595. screen:expect{grid=[[
  7596. ## grid 1
  7597. {9: + [No Name] }{3: }{11:2}{3:+ [No Name] }{5: }{9:X}|
  7598. [5:----------------------------------------]|
  7599. [5:----------------------------------------]|
  7600. [5:----------------------------------------]|
  7601. [5:----------------------------------------]|
  7602. [5:----------------------------------------]|
  7603. [3:----------------------------------------]|
  7604. ## grid 2 (hidden)
  7605. x |
  7606. {0:~ }|
  7607. {0:~ }|
  7608. {0:~ }|
  7609. {0:~ }|
  7610. ## grid 3
  7611. :tabnext |
  7612. ## grid 4
  7613. y |
  7614. {0:~ }|
  7615. {0:~ }|
  7616. {0:~ }|
  7617. ## grid 5
  7618. ^ |
  7619. {0:~ }|
  7620. {0:~ }|
  7621. {0:~ }|
  7622. {0:~ }|
  7623. ]], float_pos=expected_pos}
  7624. end
  7625. end)
  7626. end)
  7627. it("left drag changes visual selection in float window", function()
  7628. local buf = meths.create_buf(false,false)
  7629. meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'})
  7630. meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=5})
  7631. if multigrid then
  7632. screen:expect{grid=[[
  7633. ## grid 1
  7634. [2:----------------------------------------]|
  7635. [2:----------------------------------------]|
  7636. [2:----------------------------------------]|
  7637. [2:----------------------------------------]|
  7638. [2:----------------------------------------]|
  7639. [2:----------------------------------------]|
  7640. [3:----------------------------------------]|
  7641. ## grid 2
  7642. ^ |
  7643. {0:~ }|
  7644. {0:~ }|
  7645. {0:~ }|
  7646. {0:~ }|
  7647. {0:~ }|
  7648. ## grid 3
  7649. |
  7650. ## grid 5
  7651. {1:foo }|
  7652. {1:bar }|
  7653. {1:baz }|
  7654. ]], float_pos={
  7655. [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50};
  7656. }, win_viewport={
  7657. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  7658. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
  7659. }}
  7660. meths.input_mouse('left', 'press', '', 5, 0, 0)
  7661. screen:expect{grid=[[
  7662. ## grid 1
  7663. [2:----------------------------------------]|
  7664. [2:----------------------------------------]|
  7665. [2:----------------------------------------]|
  7666. [2:----------------------------------------]|
  7667. [2:----------------------------------------]|
  7668. [2:----------------------------------------]|
  7669. [3:----------------------------------------]|
  7670. ## grid 2
  7671. |
  7672. {0:~ }|
  7673. {0:~ }|
  7674. {0:~ }|
  7675. {0:~ }|
  7676. {0:~ }|
  7677. ## grid 3
  7678. |
  7679. ## grid 5
  7680. {1:^foo }|
  7681. {1:bar }|
  7682. {1:baz }|
  7683. ]], float_pos={
  7684. [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50};
  7685. }, win_viewport={
  7686. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  7687. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
  7688. }}
  7689. meths.input_mouse('left', 'drag', '', 5, 1, 2)
  7690. screen:expect{grid=[[
  7691. ## grid 1
  7692. [2:----------------------------------------]|
  7693. [2:----------------------------------------]|
  7694. [2:----------------------------------------]|
  7695. [2:----------------------------------------]|
  7696. [2:----------------------------------------]|
  7697. [2:----------------------------------------]|
  7698. [3:----------------------------------------]|
  7699. ## grid 2
  7700. |
  7701. {0:~ }|
  7702. {0:~ }|
  7703. {0:~ }|
  7704. {0:~ }|
  7705. {0:~ }|
  7706. ## grid 3
  7707. {3:-- VISUAL --} |
  7708. ## grid 5
  7709. {27:foo}{1: }|
  7710. {27:ba}{1:^r }|
  7711. {1:baz }|
  7712. ]], float_pos={
  7713. [5] = {{id = 1002}, "NW", 1, 2, 5, true, 50};
  7714. }, win_viewport={
  7715. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  7716. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0};
  7717. }}
  7718. else
  7719. screen:expect{grid=[[
  7720. ^ |
  7721. {0:~ }|
  7722. {0:~ }{1:foo }{0: }|
  7723. {0:~ }{1:bar }{0: }|
  7724. {0:~ }{1:baz }{0: }|
  7725. {0:~ }|
  7726. |
  7727. ]]}
  7728. meths.input_mouse('left', 'press', '', 0, 2, 5)
  7729. screen:expect{grid=[[
  7730. |
  7731. {0:~ }|
  7732. {0:~ }{1:^foo }{0: }|
  7733. {0:~ }{1:bar }{0: }|
  7734. {0:~ }{1:baz }{0: }|
  7735. {0:~ }|
  7736. |
  7737. ]]}
  7738. meths.input_mouse('left', 'drag', '', 0, 3, 7)
  7739. screen:expect{grid=[[
  7740. |
  7741. {0:~ }|
  7742. {0:~ }{27:foo}{1: }{0: }|
  7743. {0:~ }{27:ba}{1:^r }{0: }|
  7744. {0:~ }{1:baz }{0: }|
  7745. {0:~ }|
  7746. {3:-- VISUAL --} |
  7747. ]]}
  7748. end
  7749. end)
  7750. it("left drag changes visual selection in float window with border", function()
  7751. local buf = meths.create_buf(false,false)
  7752. meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'})
  7753. meths.open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'})
  7754. if multigrid then
  7755. screen:expect{grid=[[
  7756. ## grid 1
  7757. [2:----------------------------------------]|
  7758. [2:----------------------------------------]|
  7759. [2:----------------------------------------]|
  7760. [2:----------------------------------------]|
  7761. [2:----------------------------------------]|
  7762. [2:----------------------------------------]|
  7763. [3:----------------------------------------]|
  7764. ## grid 2
  7765. ^ |
  7766. {0:~ }|
  7767. {0:~ }|
  7768. {0:~ }|
  7769. {0:~ }|
  7770. {0:~ }|
  7771. ## grid 3
  7772. |
  7773. ## grid 5
  7774. {5:┌────────────────────┐}|
  7775. {5:│}{1:foo }{5:│}|
  7776. {5:│}{1:bar }{5:│}|
  7777. {5:│}{1:baz }{5:│}|
  7778. {5:└────────────────────┘}|
  7779. ]], float_pos={
  7780. [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50};
  7781. }, win_viewport={
  7782. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  7783. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
  7784. }}
  7785. meths.input_mouse('left', 'press', '', 5, 1, 1)
  7786. screen:expect{grid=[[
  7787. ## grid 1
  7788. [2:----------------------------------------]|
  7789. [2:----------------------------------------]|
  7790. [2:----------------------------------------]|
  7791. [2:----------------------------------------]|
  7792. [2:----------------------------------------]|
  7793. [2:----------------------------------------]|
  7794. [3:----------------------------------------]|
  7795. ## grid 2
  7796. |
  7797. {0:~ }|
  7798. {0:~ }|
  7799. {0:~ }|
  7800. {0:~ }|
  7801. {0:~ }|
  7802. ## grid 3
  7803. |
  7804. ## grid 5
  7805. {5:┌────────────────────┐}|
  7806. {5:│}{1:^foo }{5:│}|
  7807. {5:│}{1:bar }{5:│}|
  7808. {5:│}{1:baz }{5:│}|
  7809. {5:└────────────────────┘}|
  7810. ]], float_pos={
  7811. [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50};
  7812. }, win_viewport={
  7813. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  7814. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
  7815. }}
  7816. meths.input_mouse('left', 'drag', '', 5, 2, 3)
  7817. screen:expect{grid=[[
  7818. ## grid 1
  7819. [2:----------------------------------------]|
  7820. [2:----------------------------------------]|
  7821. [2:----------------------------------------]|
  7822. [2:----------------------------------------]|
  7823. [2:----------------------------------------]|
  7824. [2:----------------------------------------]|
  7825. [3:----------------------------------------]|
  7826. ## grid 2
  7827. |
  7828. {0:~ }|
  7829. {0:~ }|
  7830. {0:~ }|
  7831. {0:~ }|
  7832. {0:~ }|
  7833. ## grid 3
  7834. {3:-- VISUAL --} |
  7835. ## grid 5
  7836. {5:┌────────────────────┐}|
  7837. {5:│}{27:foo}{1: }{5:│}|
  7838. {5:│}{27:ba}{1:^r }{5:│}|
  7839. {5:│}{1:baz }{5:│}|
  7840. {5:└────────────────────┘}|
  7841. ]], float_pos={
  7842. [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50};
  7843. }, win_viewport={
  7844. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  7845. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0};
  7846. }}
  7847. else
  7848. screen:expect{grid=[[
  7849. ^ {5:┌────────────────────┐} |
  7850. {0:~ }{5:│}{1:foo }{5:│}{0: }|
  7851. {0:~ }{5:│}{1:bar }{5:│}{0: }|
  7852. {0:~ }{5:│}{1:baz }{5:│}{0: }|
  7853. {0:~ }{5:└────────────────────┘}{0: }|
  7854. {0:~ }|
  7855. |
  7856. ]]}
  7857. meths.input_mouse('left', 'press', '', 0, 1, 6)
  7858. screen:expect{grid=[[
  7859. {5:┌────────────────────┐} |
  7860. {0:~ }{5:│}{1:^foo }{5:│}{0: }|
  7861. {0:~ }{5:│}{1:bar }{5:│}{0: }|
  7862. {0:~ }{5:│}{1:baz }{5:│}{0: }|
  7863. {0:~ }{5:└────────────────────┘}{0: }|
  7864. {0:~ }|
  7865. |
  7866. ]]}
  7867. meths.input_mouse('left', 'drag', '', 0, 2, 8)
  7868. screen:expect{grid=[[
  7869. {5:┌────────────────────┐} |
  7870. {0:~ }{5:│}{27:foo}{1: }{5:│}{0: }|
  7871. {0:~ }{5:│}{27:ba}{1:^r }{5:│}{0: }|
  7872. {0:~ }{5:│}{1:baz }{5:│}{0: }|
  7873. {0:~ }{5:└────────────────────┘}{0: }|
  7874. {0:~ }|
  7875. {3:-- VISUAL --} |
  7876. ]]}
  7877. end
  7878. end)
  7879. it("left drag changes visual selection in float window with winbar", function()
  7880. local buf = meths.create_buf(false,false)
  7881. meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'})
  7882. local float_win = meths.open_win(buf, false, {relative='editor', width=20, height=4, row=1, col=5})
  7883. meths.win_set_option(float_win, 'winbar', 'floaty bar')
  7884. if multigrid then
  7885. screen:expect{grid=[[
  7886. ## grid 1
  7887. [2:----------------------------------------]|
  7888. [2:----------------------------------------]|
  7889. [2:----------------------------------------]|
  7890. [2:----------------------------------------]|
  7891. [2:----------------------------------------]|
  7892. [2:----------------------------------------]|
  7893. [3:----------------------------------------]|
  7894. ## grid 2
  7895. ^ |
  7896. {0:~ }|
  7897. {0:~ }|
  7898. {0:~ }|
  7899. {0:~ }|
  7900. {0:~ }|
  7901. ## grid 3
  7902. |
  7903. ## grid 5
  7904. {3:floaty bar }|
  7905. {1:foo }|
  7906. {1:bar }|
  7907. {1:baz }|
  7908. ]], float_pos={
  7909. [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50};
  7910. }, win_viewport={
  7911. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  7912. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
  7913. }}
  7914. meths.input_mouse('left', 'press', '', 5, 1, 0)
  7915. screen:expect{grid=[[
  7916. ## grid 1
  7917. [2:----------------------------------------]|
  7918. [2:----------------------------------------]|
  7919. [2:----------------------------------------]|
  7920. [2:----------------------------------------]|
  7921. [2:----------------------------------------]|
  7922. [2:----------------------------------------]|
  7923. [3:----------------------------------------]|
  7924. ## grid 2
  7925. |
  7926. {0:~ }|
  7927. {0:~ }|
  7928. {0:~ }|
  7929. {0:~ }|
  7930. {0:~ }|
  7931. ## grid 3
  7932. |
  7933. ## grid 5
  7934. {3:floaty bar }|
  7935. {1:^foo }|
  7936. {1:bar }|
  7937. {1:baz }|
  7938. ]], float_pos={
  7939. [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50};
  7940. }, win_viewport={
  7941. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  7942. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0};
  7943. }}
  7944. meths.input_mouse('left', 'drag', '', 5, 2, 2)
  7945. screen:expect{grid=[[
  7946. ## grid 1
  7947. [2:----------------------------------------]|
  7948. [2:----------------------------------------]|
  7949. [2:----------------------------------------]|
  7950. [2:----------------------------------------]|
  7951. [2:----------------------------------------]|
  7952. [2:----------------------------------------]|
  7953. [3:----------------------------------------]|
  7954. ## grid 2
  7955. |
  7956. {0:~ }|
  7957. {0:~ }|
  7958. {0:~ }|
  7959. {0:~ }|
  7960. {0:~ }|
  7961. ## grid 3
  7962. {3:-- VISUAL --} |
  7963. ## grid 5
  7964. {3:floaty bar }|
  7965. {27:foo}{1: }|
  7966. {27:ba}{1:^r }|
  7967. {1:baz }|
  7968. ]], float_pos={
  7969. [5] = {{id = 1002}, "NW", 1, 1, 5, true, 50};
  7970. }, win_viewport={
  7971. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  7972. [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0};
  7973. }}
  7974. else
  7975. screen:expect{grid=[[
  7976. ^ |
  7977. {0:~ }{3:floaty bar }{0: }|
  7978. {0:~ }{1:foo }{0: }|
  7979. {0:~ }{1:bar }{0: }|
  7980. {0:~ }{1:baz }{0: }|
  7981. {0:~ }|
  7982. |
  7983. ]]}
  7984. meths.input_mouse('left', 'press', '', 0, 2, 5)
  7985. screen:expect{grid=[[
  7986. |
  7987. {0:~ }{3:floaty bar }{0: }|
  7988. {0:~ }{1:^foo }{0: }|
  7989. {0:~ }{1:bar }{0: }|
  7990. {0:~ }{1:baz }{0: }|
  7991. {0:~ }|
  7992. |
  7993. ]]}
  7994. meths.input_mouse('left', 'drag', '', 0, 3, 7)
  7995. screen:expect{grid=[[
  7996. |
  7997. {0:~ }{3:floaty bar }{0: }|
  7998. {0:~ }{27:foo}{1: }{0: }|
  7999. {0:~ }{27:ba}{1:^r }{0: }|
  8000. {0:~ }{1:baz }{0: }|
  8001. {0:~ }|
  8002. {3:-- VISUAL --} |
  8003. ]]}
  8004. end
  8005. end)
  8006. it('left drag changes visual selection if float window is turned into a split', function()
  8007. local buf = meths.create_buf(false,false)
  8008. meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'})
  8009. meths.open_win(buf, true, {relative='editor', width=20, height=3, row=2, col=5})
  8010. command('wincmd L')
  8011. if multigrid then
  8012. screen:expect([[
  8013. ## grid 1
  8014. [2:-------------------]{5:│}[5:--------------------]|
  8015. [2:-------------------]{5:│}[5:--------------------]|
  8016. [2:-------------------]{5:│}[5:--------------------]|
  8017. [2:-------------------]{5:│}[5:--------------------]|
  8018. [2:-------------------]{5:│}[5:--------------------]|
  8019. {5:[No Name] }{4:[No Name] [+] }|
  8020. [3:----------------------------------------]|
  8021. ## grid 2
  8022. |
  8023. {0:~ }|
  8024. {0:~ }|
  8025. {0:~ }|
  8026. {0:~ }|
  8027. ## grid 3
  8028. |
  8029. ## grid 5
  8030. ^foo |
  8031. bar |
  8032. baz |
  8033. {0:~ }|
  8034. {0:~ }|
  8035. ]])
  8036. meths.input_mouse('left', 'press', '', 5, 2, 2)
  8037. screen:expect([[
  8038. ## grid 1
  8039. [2:-------------------]{5:│}[5:--------------------]|
  8040. [2:-------------------]{5:│}[5:--------------------]|
  8041. [2:-------------------]{5:│}[5:--------------------]|
  8042. [2:-------------------]{5:│}[5:--------------------]|
  8043. [2:-------------------]{5:│}[5:--------------------]|
  8044. {5:[No Name] }{4:[No Name] [+] }|
  8045. [3:----------------------------------------]|
  8046. ## grid 2
  8047. |
  8048. {0:~ }|
  8049. {0:~ }|
  8050. {0:~ }|
  8051. {0:~ }|
  8052. ## grid 3
  8053. |
  8054. ## grid 5
  8055. foo |
  8056. bar |
  8057. ba^z |
  8058. {0:~ }|
  8059. {0:~ }|
  8060. ]])
  8061. meths.input_mouse('left', 'drag', '', 5, 1, 1)
  8062. screen:expect([[
  8063. ## grid 1
  8064. [2:-------------------]{5:│}[5:--------------------]|
  8065. [2:-------------------]{5:│}[5:--------------------]|
  8066. [2:-------------------]{5:│}[5:--------------------]|
  8067. [2:-------------------]{5:│}[5:--------------------]|
  8068. [2:-------------------]{5:│}[5:--------------------]|
  8069. {5:[No Name] }{4:[No Name] [+] }|
  8070. [3:----------------------------------------]|
  8071. ## grid 2
  8072. |
  8073. {0:~ }|
  8074. {0:~ }|
  8075. {0:~ }|
  8076. {0:~ }|
  8077. ## grid 3
  8078. {3:-- VISUAL --} |
  8079. ## grid 5
  8080. foo |
  8081. b^a{27:r} |
  8082. {27:baz} |
  8083. {0:~ }|
  8084. {0:~ }|
  8085. ]])
  8086. else
  8087. screen:expect([[
  8088. {5:│}^foo |
  8089. {0:~ }{5:│}bar |
  8090. {0:~ }{5:│}baz |
  8091. {0:~ }{5:│}{0:~ }|
  8092. {0:~ }{5:│}{0:~ }|
  8093. {5:[No Name] }{4:[No Name] [+] }|
  8094. |
  8095. ]])
  8096. meths.input_mouse('left', 'press', '', 0, 2, 22)
  8097. screen:expect([[
  8098. {5:│}foo |
  8099. {0:~ }{5:│}bar |
  8100. {0:~ }{5:│}ba^z |
  8101. {0:~ }{5:│}{0:~ }|
  8102. {0:~ }{5:│}{0:~ }|
  8103. {5:[No Name] }{4:[No Name] [+] }|
  8104. |
  8105. ]])
  8106. meths.input_mouse('left', 'drag', '', 0, 1, 21)
  8107. screen:expect([[
  8108. {5:│}foo |
  8109. {0:~ }{5:│}b^a{27:r} |
  8110. {0:~ }{5:│}{27:baz} |
  8111. {0:~ }{5:│}{0:~ }|
  8112. {0:~ }{5:│}{0:~ }|
  8113. {5:[No Name] }{4:[No Name] [+] }|
  8114. {3:-- VISUAL --} |
  8115. ]])
  8116. end
  8117. end)
  8118. it("'winblend' option", function()
  8119. screen:try_resize(50,9)
  8120. screen:set_default_attr_ids({
  8121. [1] = {background = Screen.colors.LightMagenta},
  8122. [2] = {foreground = Screen.colors.Grey0, background = tonumber('0xffcfff')},
  8123. [3] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')},
  8124. [4] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta},
  8125. [5] = {foreground = tonumber('0x990000'), background = tonumber('0xfff1ff')},
  8126. [6] = {foreground = tonumber('0x332533'), background = tonumber('0xfff1ff')},
  8127. [7] = {background = tonumber('0xffcfff'), bold = true, foreground = tonumber('0x0000d8')},
  8128. [8] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1},
  8129. [9] = {background = Screen.colors.LightMagenta, blend = 30},
  8130. [10] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta, blend = 0},
  8131. [11] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta, blend = 80},
  8132. [12] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1, blend = 30},
  8133. [13] = {background = Screen.colors.LightGray, blend = 30},
  8134. [14] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey88},
  8135. [15] = {foreground = tonumber('0x939393'), background = Screen.colors.Grey88},
  8136. [16] = {background = Screen.colors.Grey90};
  8137. [17] = {blend = 100};
  8138. [18] = {background = Screen.colors.LightMagenta, blend = 100};
  8139. [19] = {background = Screen.colors.LightMagenta, bold = true, blend = 100, foreground = Screen.colors.Blue1};
  8140. [20] = {background = Screen.colors.White, foreground = Screen.colors.Gray0};
  8141. [21] = {background = Screen.colors.White, bold = true, foreground = tonumber('0x00007f')};
  8142. [22] = {background = Screen.colors.Gray90, foreground = Screen.colors.Gray0};
  8143. })
  8144. insert([[
  8145. Lorem ipsum dolor sit amet, consectetur
  8146. adipisicing elit, sed do eiusmod tempor
  8147. incididunt ut labore et dolore magna aliqua.
  8148. Ut enim ad minim veniam, quis nostrud
  8149. exercitation ullamco laboris nisi ut aliquip ex
  8150. ea commodo consequat. Duis aute irure dolor in
  8151. reprehenderit in voluptate velit esse cillum
  8152. dolore eu fugiat nulla pariatur. Excepteur sint
  8153. occaecat cupidatat non proident, sunt in culpa
  8154. qui officia deserunt mollit anim id est
  8155. laborum.]])
  8156. local buf = meths.create_buf(false,false)
  8157. meths.buf_set_lines(buf, 0, -1, true, {"test", "", "popup text"})
  8158. local win = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=2, col=5})
  8159. if multigrid then
  8160. screen:expect{grid=[[
  8161. ## grid 1
  8162. [2:--------------------------------------------------]|
  8163. [2:--------------------------------------------------]|
  8164. [2:--------------------------------------------------]|
  8165. [2:--------------------------------------------------]|
  8166. [2:--------------------------------------------------]|
  8167. [2:--------------------------------------------------]|
  8168. [2:--------------------------------------------------]|
  8169. [2:--------------------------------------------------]|
  8170. [3:--------------------------------------------------]|
  8171. ## grid 2
  8172. Ut enim ad minim veniam, quis nostrud |
  8173. exercitation ullamco laboris nisi ut aliquip ex |
  8174. ea commodo consequat. Duis aute irure dolor in |
  8175. reprehenderit in voluptate velit esse cillum |
  8176. dolore eu fugiat nulla pariatur. Excepteur sint |
  8177. occaecat cupidatat non proident, sunt in culpa |
  8178. qui officia deserunt mollit anim id est |
  8179. laborum^. |
  8180. ## grid 3
  8181. |
  8182. ## grid 5
  8183. {1:test }|
  8184. {1: }|
  8185. {1:popup text }|
  8186. ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}}
  8187. else
  8188. screen:expect([[
  8189. Ut enim ad minim veniam, quis nostrud |
  8190. exercitation ullamco laboris nisi ut aliquip ex |
  8191. ea co{1:test }. Duis aute irure dolor in |
  8192. repre{1: }uptate velit esse cillum |
  8193. dolor{1:popup text }la pariatur. Excepteur sint |
  8194. occaecat cupidatat non proident, sunt in culpa |
  8195. qui officia deserunt mollit anim id est |
  8196. laborum^. |
  8197. |
  8198. ]])
  8199. end
  8200. meths.win_set_option(win, "winblend", 30)
  8201. if multigrid then
  8202. screen:expect{grid=[[
  8203. ## grid 1
  8204. [2:--------------------------------------------------]|
  8205. [2:--------------------------------------------------]|
  8206. [2:--------------------------------------------------]|
  8207. [2:--------------------------------------------------]|
  8208. [2:--------------------------------------------------]|
  8209. [2:--------------------------------------------------]|
  8210. [2:--------------------------------------------------]|
  8211. [2:--------------------------------------------------]|
  8212. [3:--------------------------------------------------]|
  8213. ## grid 2
  8214. Ut enim ad minim veniam, quis nostrud |
  8215. exercitation ullamco laboris nisi ut aliquip ex |
  8216. ea commodo consequat. Duis aute irure dolor in |
  8217. reprehenderit in voluptate velit esse cillum |
  8218. dolore eu fugiat nulla pariatur. Excepteur sint |
  8219. occaecat cupidatat non proident, sunt in culpa |
  8220. qui officia deserunt mollit anim id est |
  8221. laborum^. |
  8222. ## grid 3
  8223. |
  8224. ## grid 5
  8225. {9:test }|
  8226. {9: }|
  8227. {9:popup text }|
  8228. ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}, unchanged=true}
  8229. else
  8230. screen:expect([[
  8231. Ut enim ad minim veniam, quis nostrud |
  8232. exercitation ullamco laboris nisi ut aliquip ex |
  8233. ea co{2:test}{3:o consequat}. Duis aute irure dolor in |
  8234. repre{3:henderit in vol}uptate velit esse cillum |
  8235. dolor{2:popup}{3:fugi}{2:text}{3:ul}la pariatur. Excepteur sint |
  8236. occaecat cupidatat non proident, sunt in culpa |
  8237. qui officia deserunt mollit anim id est |
  8238. laborum^. |
  8239. |
  8240. ]])
  8241. end
  8242. -- Check that 'winblend' works with NormalNC highlight
  8243. meths.set_option_value('winhighlight', 'NormalNC:Visual', {win = win})
  8244. if multigrid then
  8245. screen:expect{grid=[[
  8246. ## grid 1
  8247. [2:--------------------------------------------------]|
  8248. [2:--------------------------------------------------]|
  8249. [2:--------------------------------------------------]|
  8250. [2:--------------------------------------------------]|
  8251. [2:--------------------------------------------------]|
  8252. [2:--------------------------------------------------]|
  8253. [2:--------------------------------------------------]|
  8254. [2:--------------------------------------------------]|
  8255. [3:--------------------------------------------------]|
  8256. ## grid 2
  8257. Ut enim ad minim veniam, quis nostrud |
  8258. exercitation ullamco laboris nisi ut aliquip ex |
  8259. ea commodo consequat. Duis aute irure dolor in |
  8260. reprehenderit in voluptate velit esse cillum |
  8261. dolore eu fugiat nulla pariatur. Excepteur sint |
  8262. occaecat cupidatat non proident, sunt in culpa |
  8263. qui officia deserunt mollit anim id est |
  8264. laborum^. |
  8265. ## grid 3
  8266. |
  8267. ## grid 5
  8268. {13:test }|
  8269. {13: }|
  8270. {13:popup text }|
  8271. ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}}
  8272. else
  8273. screen:expect([[
  8274. Ut enim ad minim veniam, quis nostrud |
  8275. exercitation ullamco laboris nisi ut aliquip ex |
  8276. ea co{14:test}{15:o consequat}. Duis aute irure dolor in |
  8277. repre{15:henderit in vol}uptate velit esse cillum |
  8278. dolor{14:popup}{15:fugi}{14:text}{15:ul}la pariatur. Excepteur sint |
  8279. occaecat cupidatat non proident, sunt in culpa |
  8280. qui officia deserunt mollit anim id est |
  8281. laborum^. |
  8282. |
  8283. ]])
  8284. end
  8285. -- Also test with global NormalNC highlight
  8286. meths.set_option_value('winhighlight', '', {win = win})
  8287. command('hi link NormalNC Visual')
  8288. screen:expect_unchanged(true)
  8289. command('hi clear NormalNC')
  8290. command('hi SpecialRegion guifg=Red blend=0')
  8291. meths.buf_add_highlight(buf, -1, "SpecialRegion", 2, 0, -1)
  8292. if multigrid then
  8293. screen:expect{grid=[[
  8294. ## grid 1
  8295. [2:--------------------------------------------------]|
  8296. [2:--------------------------------------------------]|
  8297. [2:--------------------------------------------------]|
  8298. [2:--------------------------------------------------]|
  8299. [2:--------------------------------------------------]|
  8300. [2:--------------------------------------------------]|
  8301. [2:--------------------------------------------------]|
  8302. [2:--------------------------------------------------]|
  8303. [3:--------------------------------------------------]|
  8304. ## grid 2
  8305. Ut enim ad minim veniam, quis nostrud |
  8306. exercitation ullamco laboris nisi ut aliquip ex |
  8307. ea commodo consequat. Duis aute irure dolor in |
  8308. reprehenderit in voluptate velit esse cillum |
  8309. dolore eu fugiat nulla pariatur. Excepteur sint |
  8310. occaecat cupidatat non proident, sunt in culpa |
  8311. qui officia deserunt mollit anim id est |
  8312. laborum^. |
  8313. ## grid 3
  8314. |
  8315. ## grid 5
  8316. {9:test }|
  8317. {9: }|
  8318. {10:popup text}{9: }|
  8319. ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}}
  8320. else
  8321. screen:expect([[
  8322. Ut enim ad minim veniam, quis nostrud |
  8323. exercitation ullamco laboris nisi ut aliquip ex |
  8324. ea co{2:test}{3:o consequat}. Duis aute irure dolor in |
  8325. repre{3:henderit in vol}uptate velit esse cillum |
  8326. dolor{10:popup text}{3:ul}la pariatur. Excepteur sint |
  8327. occaecat cupidatat non proident, sunt in culpa |
  8328. qui officia deserunt mollit anim id est |
  8329. laborum^. |
  8330. |
  8331. ]])
  8332. end
  8333. command('hi SpecialRegion guifg=Red blend=80')
  8334. if multigrid then
  8335. screen:expect{grid=[[
  8336. ## grid 1
  8337. [2:--------------------------------------------------]|
  8338. [2:--------------------------------------------------]|
  8339. [2:--------------------------------------------------]|
  8340. [2:--------------------------------------------------]|
  8341. [2:--------------------------------------------------]|
  8342. [2:--------------------------------------------------]|
  8343. [2:--------------------------------------------------]|
  8344. [2:--------------------------------------------------]|
  8345. [3:--------------------------------------------------]|
  8346. ## grid 2
  8347. Ut enim ad minim veniam, quis nostrud |
  8348. exercitation ullamco laboris nisi ut aliquip ex |
  8349. ea commodo consequat. Duis aute irure dolor in |
  8350. reprehenderit in voluptate velit esse cillum |
  8351. dolore eu fugiat nulla pariatur. Excepteur sint |
  8352. occaecat cupidatat non proident, sunt in culpa |
  8353. qui officia deserunt mollit anim id est |
  8354. laborum^. |
  8355. ## grid 3
  8356. |
  8357. ## grid 5
  8358. {9:test }|
  8359. {9: }|
  8360. {11:popup text}{9: }|
  8361. ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}, unchanged=true}
  8362. else
  8363. screen:expect([[
  8364. Ut enim ad minim veniam, quis nostrud |
  8365. exercitation ullamco laboris nisi ut aliquip ex |
  8366. ea co{2:test}{3:o consequat}. Duis aute irure dolor in |
  8367. repre{3:henderit in vol}uptate velit esse cillum |
  8368. dolor{5:popup}{6:fugi}{5:text}{3:ul}la pariatur. Excepteur sint |
  8369. occaecat cupidatat non proident, sunt in culpa |
  8370. qui officia deserunt mollit anim id est |
  8371. laborum^. |
  8372. |
  8373. ]])
  8374. end
  8375. -- Test scrolling by mouse
  8376. if multigrid then
  8377. meths.input_mouse('wheel', 'down', '', 5, 2, 2)
  8378. screen:expect{grid=[[
  8379. ## grid 1
  8380. [2:--------------------------------------------------]|
  8381. [2:--------------------------------------------------]|
  8382. [2:--------------------------------------------------]|
  8383. [2:--------------------------------------------------]|
  8384. [2:--------------------------------------------------]|
  8385. [2:--------------------------------------------------]|
  8386. [2:--------------------------------------------------]|
  8387. [2:--------------------------------------------------]|
  8388. [3:--------------------------------------------------]|
  8389. ## grid 2
  8390. Ut enim ad minim veniam, quis nostrud |
  8391. exercitation ullamco laboris nisi ut aliquip ex |
  8392. ea commodo consequat. Duis aute irure dolor in |
  8393. reprehenderit in voluptate velit esse cillum |
  8394. dolore eu fugiat nulla pariatur. Excepteur sint |
  8395. occaecat cupidatat non proident, sunt in culpa |
  8396. qui officia deserunt mollit anim id est |
  8397. laborum^. |
  8398. ## grid 3
  8399. |
  8400. ## grid 5
  8401. {11:popup text}{9: }|
  8402. {12:~ }|
  8403. {12:~ }|
  8404. ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}}
  8405. else
  8406. meths.input_mouse('wheel', 'down', '', 0, 4, 7)
  8407. screen:expect([[
  8408. Ut enim ad minim veniam, quis nostrud |
  8409. exercitation ullamco laboris nisi ut aliquip ex |
  8410. ea co{5:popup}{6: con}{5:text}{3:at}. Duis aute irure dolor in |
  8411. repre{7:~}{3:enderit in vol}uptate velit esse cillum |
  8412. dolor{7:~}{3: eu fugiat nul}la pariatur. Excepteur sint |
  8413. occaecat cupidatat non proident, sunt in culpa |
  8414. qui officia deserunt mollit anim id est |
  8415. laborum^. |
  8416. |
  8417. ]])
  8418. end
  8419. -- Check that 'winblend' applies to border
  8420. meths.win_set_config(win, {border='single'})
  8421. meths.set_option_value('winblend', 100, {win=win.id})
  8422. meths.set_option_value("cursorline", true, {win=0})
  8423. command('hi clear VertSplit')
  8424. feed('k0')
  8425. if multigrid then
  8426. screen:expect{grid=[[
  8427. ## grid 1
  8428. [2:--------------------------------------------------]|
  8429. [2:--------------------------------------------------]|
  8430. [2:--------------------------------------------------]|
  8431. [2:--------------------------------------------------]|
  8432. [2:--------------------------------------------------]|
  8433. [2:--------------------------------------------------]|
  8434. [2:--------------------------------------------------]|
  8435. [2:--------------------------------------------------]|
  8436. [3:--------------------------------------------------]|
  8437. ## grid 2
  8438. Ut enim ad minim veniam, quis nostrud |
  8439. exercitation ullamco laboris nisi ut aliquip ex |
  8440. ea commodo consequat. Duis aute irure dolor in |
  8441. reprehenderit in voluptate velit esse cillum |
  8442. dolore eu fugiat nulla pariatur. Excepteur sint |
  8443. occaecat cupidatat non proident, sunt in culpa |
  8444. {16:^qui officia deserunt mollit anim id est }|
  8445. laborum. |
  8446. ## grid 3
  8447. |
  8448. ## grid 5
  8449. {17:┌───────────────┐}|
  8450. {17:│}{11:popup text}{18: }{17:│}|
  8451. {17:│}{19:~ }{17:│}|
  8452. {17:│}{19:~ }{17:│}|
  8453. {17:└───────────────┘}|
  8454. ]], float_pos={[5] = {{id = 1002}, "NW", 1, 2, 5, true}}}
  8455. else
  8456. screen:expect([[
  8457. Ut enim ad minim veniam, quis nostrud |
  8458. exercitation ullamco laboris nisi ut aliquip ex |
  8459. ea co{20:┌───────────────┐}Duis aute irure dolor in |
  8460. repre{20:│}{5:popup}{6:it i}{5:text}{20:lu│}tate velit esse cillum |
  8461. dolor{20:│}{21:~}{20:eu fugiat null│} pariatur. Excepteur sint |
  8462. occae{20:│}{21:~}{20:t cupidatat no│} proident, sunt in culpa |
  8463. {16:^qui o}{22:└───────────────┘}{16:ollit anim id est }|
  8464. laborum. |
  8465. |
  8466. ]])
  8467. end
  8468. end)
  8469. it('can overlap doublewidth chars', function()
  8470. insert([[
  8471. # TODO: 测试字典信息的准确性
  8472. # FIXME: 测试字典信息的准确性]])
  8473. local buf = meths.create_buf(false,false)
  8474. meths.buf_set_lines(buf, 0, -1, true, {'口', '口'})
  8475. local win = meths.open_win(buf, false, {relative='editor', width=5, height=3, row=0, col=11, style='minimal'})
  8476. if multigrid then
  8477. screen:expect{grid=[[
  8478. ## grid 1
  8479. [2:----------------------------------------]|
  8480. [2:----------------------------------------]|
  8481. [2:----------------------------------------]|
  8482. [2:----------------------------------------]|
  8483. [2:----------------------------------------]|
  8484. [2:----------------------------------------]|
  8485. [3:----------------------------------------]|
  8486. ## grid 2
  8487. # TODO: 测试字典信息的准确性 |
  8488. # FIXME: 测试字典信息的准确^性 |
  8489. {0:~ }|
  8490. {0:~ }|
  8491. {0:~ }|
  8492. {0:~ }|
  8493. ## grid 3
  8494. |
  8495. ## grid 5
  8496. {1:口 }|
  8497. {1:口 }|
  8498. {1: }|
  8499. ]], float_pos={ [5] = { { id = 1002 }, "NW", 1, 0, 11, true } }}
  8500. else
  8501. screen:expect([[
  8502. # TODO: 测 {1:口 }信息的准确性 |
  8503. # FIXME: 测{1:口 } 信息的准确^性 |
  8504. {0:~ }{1: }{0: }|
  8505. {0:~ }|
  8506. {0:~ }|
  8507. {0:~ }|
  8508. |
  8509. ]])
  8510. end
  8511. meths.win_close(win, false)
  8512. if multigrid then
  8513. screen:expect([[
  8514. ## grid 1
  8515. [2:----------------------------------------]|
  8516. [2:----------------------------------------]|
  8517. [2:----------------------------------------]|
  8518. [2:----------------------------------------]|
  8519. [2:----------------------------------------]|
  8520. [2:----------------------------------------]|
  8521. [3:----------------------------------------]|
  8522. ## grid 2
  8523. # TODO: 测试字典信息的准确性 |
  8524. # FIXME: 测试字典信息的准确^性 |
  8525. {0:~ }|
  8526. {0:~ }|
  8527. {0:~ }|
  8528. {0:~ }|
  8529. ## grid 3
  8530. |
  8531. ]])
  8532. else
  8533. screen:expect([[
  8534. # TODO: 测试字典信息的准确性 |
  8535. # FIXME: 测试字典信息的准确^性 |
  8536. {0:~ }|
  8537. {0:~ }|
  8538. {0:~ }|
  8539. {0:~ }|
  8540. |
  8541. ]])
  8542. end
  8543. -- The interaction between 'winblend' and doublewidth chars in the background
  8544. -- does not look very good. But check no chars get incorrectly placed
  8545. -- at least. Also check invisible EndOfBuffer region blends correctly.
  8546. meths.buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"})
  8547. win = meths.open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'})
  8548. meths.win_set_option(win, 'winblend', 30)
  8549. screen:set_default_attr_ids({
  8550. [1] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')},
  8551. [2] = {foreground = Screen.colors.Grey0, background = tonumber('0xffcfff')},
  8552. [3] = {bold = true, foreground = Screen.colors.Blue1},
  8553. [4] = {background = tonumber('0xffcfff'), bold = true, foreground = tonumber('0xb282ff')},
  8554. [5] = {background = Screen.colors.LightMagenta, blend=30},
  8555. })
  8556. if multigrid then
  8557. screen:expect{grid=[[
  8558. ## grid 1
  8559. [2:----------------------------------------]|
  8560. [2:----------------------------------------]|
  8561. [2:----------------------------------------]|
  8562. [2:----------------------------------------]|
  8563. [2:----------------------------------------]|
  8564. [2:----------------------------------------]|
  8565. [3:----------------------------------------]|
  8566. ## grid 2
  8567. # TODO: 测试字典信息的准确性 |
  8568. # FIXME: 测试字典信息的准确^性 |
  8569. {3:~ }|
  8570. {3:~ }|
  8571. {3:~ }|
  8572. {3:~ }|
  8573. ## grid 3
  8574. |
  8575. ## grid 6
  8576. {5: x x x xx}|
  8577. {5: x x x x}|
  8578. {5: }|
  8579. ]], float_pos={
  8580. [6] = { {
  8581. id = 1003
  8582. }, "NW", 1, 0, 11, true }
  8583. }}
  8584. else
  8585. screen:expect([[
  8586. # TODO: 测 {2: x x x}{1:息}{2: xx} 确性 |
  8587. # FIXME: 测{1:试}{2:x x x}{1:息}{2: x}准确^性 |
  8588. {3:~ }{4: }{3: }|
  8589. {3:~ }|
  8590. {3:~ }|
  8591. {3:~ }|
  8592. |
  8593. ]])
  8594. end
  8595. meths.win_set_config(win, {relative='editor', row=0, col=12})
  8596. if multigrid then
  8597. screen:expect{grid=[[
  8598. ## grid 1
  8599. [2:----------------------------------------]|
  8600. [2:----------------------------------------]|
  8601. [2:----------------------------------------]|
  8602. [2:----------------------------------------]|
  8603. [2:----------------------------------------]|
  8604. [2:----------------------------------------]|
  8605. [3:----------------------------------------]|
  8606. ## grid 2
  8607. # TODO: 测试字典信息的准确性 |
  8608. # FIXME: 测试字典信息的准确^性 |
  8609. {3:~ }|
  8610. {3:~ }|
  8611. {3:~ }|
  8612. {3:~ }|
  8613. ## grid 3
  8614. |
  8615. ## grid 6
  8616. {5: x x x xx}|
  8617. {5: x x x x}|
  8618. {5: }|
  8619. ]], float_pos={
  8620. [6] = { {
  8621. id = 1003
  8622. }, "NW", 1, 0, 12, true }
  8623. }}
  8624. else
  8625. screen:expect([[
  8626. # TODO: 测试{2: x x}{1:信}{2:x }{1:的}{2:xx}确性 |
  8627. # FIXME: 测 {2: x x}{1:信}{2:x }{1:的}{2:x} 确^性 |
  8628. {3:~ }{4: }{3: }|
  8629. {3:~ }|
  8630. {3:~ }|
  8631. {3:~ }|
  8632. |
  8633. ]])
  8634. end
  8635. end)
  8636. it("correctly redraws when overlaid windows are resized #13991", function()
  8637. helpers.source([[
  8638. let popup_config = {"relative" : "editor",
  8639. \ "width" : 7,
  8640. \ "height" : 3,
  8641. \ "row" : 1,
  8642. \ "col" : 1,
  8643. \ "style" : "minimal"}
  8644. let border_config = {"relative" : "editor",
  8645. \ "width" : 9,
  8646. \ "height" : 5,
  8647. \ "row" : 0,
  8648. \ "col" : 0,
  8649. \ "style" : "minimal"}
  8650. let popup_buffer = nvim_create_buf(v:false, v:true)
  8651. let border_buffer = nvim_create_buf(v:false, v:true)
  8652. let popup_win = nvim_open_win(popup_buffer, v:true, popup_config)
  8653. let border_win = nvim_open_win(border_buffer, v:false, border_config)
  8654. call nvim_buf_set_lines(popup_buffer, 0, -1, v:true,
  8655. \ ["long", "longer", "longest"])
  8656. call nvim_buf_set_lines(border_buffer, 0, -1, v:true,
  8657. \ ["---------", "- -", "- -"])
  8658. ]])
  8659. if multigrid then
  8660. screen:expect{grid=[[
  8661. ## grid 1
  8662. [2:----------------------------------------]|
  8663. [2:----------------------------------------]|
  8664. [2:----------------------------------------]|
  8665. [2:----------------------------------------]|
  8666. [2:----------------------------------------]|
  8667. [2:----------------------------------------]|
  8668. [3:----------------------------------------]|
  8669. ## grid 2
  8670. |
  8671. {1:~ }|
  8672. {1:~ }|
  8673. {1:~ }|
  8674. {1:~ }|
  8675. {1:~ }|
  8676. ## grid 3
  8677. |
  8678. ## grid 5
  8679. {2:^long }|
  8680. {2:longer }|
  8681. {2:longest}|
  8682. ## grid 6
  8683. {2:---------}|
  8684. {2:- -}|
  8685. {2:- -}|
  8686. {2: }|
  8687. {2: }|
  8688. ]], attr_ids={
  8689. [1] = {foreground = Screen.colors.Blue1, bold = true};
  8690. [2] = {background = Screen.colors.LightMagenta};
  8691. }, float_pos={
  8692. [5] = { {
  8693. id = 1002
  8694. }, "NW", 1, 1, 1, true },
  8695. [6] = { {
  8696. id = 1003
  8697. }, "NW", 1, 0, 0, true }
  8698. }}
  8699. else
  8700. screen:expect([[
  8701. {1:---------} |
  8702. {1:-^long -}{0: }|
  8703. {1:-longer -}{0: }|
  8704. {1: longest }{0: }|
  8705. {1: }{0: }|
  8706. {0:~ }|
  8707. |
  8708. ]])
  8709. end
  8710. helpers.source([[
  8711. let new_popup_config = {"width" : 1, "height" : 3}
  8712. let new_border_config = {"width" : 3, "height" : 5}
  8713. function! Resize()
  8714. call nvim_win_set_config(g:popup_win, g:new_popup_config)
  8715. call nvim_win_set_config(g:border_win, g:new_border_config)
  8716. call nvim_buf_set_lines(g:border_buffer, 0, -1, v:true,
  8717. \ ["---", "- -", "- -"])
  8718. endfunction
  8719. nnoremap zz <cmd>call Resize()<cr>
  8720. ]])
  8721. helpers.feed("zz")
  8722. if multigrid then
  8723. screen:expect{grid=[[
  8724. ## grid 1
  8725. [2:----------------------------------------]|
  8726. [2:----------------------------------------]|
  8727. [2:----------------------------------------]|
  8728. [2:----------------------------------------]|
  8729. [2:----------------------------------------]|
  8730. [2:----------------------------------------]|
  8731. [3:----------------------------------------]|
  8732. ## grid 2
  8733. |
  8734. {1:~ }|
  8735. {1:~ }|
  8736. {1:~ }|
  8737. {1:~ }|
  8738. {1:~ }|
  8739. ## grid 3
  8740. |
  8741. ## grid 5
  8742. {2:^l}|
  8743. {2:o}|
  8744. {2:n}|
  8745. ## grid 6
  8746. {2:---}|
  8747. {2:- -}|
  8748. {2:- -}|
  8749. {2: }|
  8750. {2: }|
  8751. ]], attr_ids={
  8752. [1] = {foreground = Screen.colors.Blue1, bold = true};
  8753. [2] = {background = Screen.colors.LightMagenta};
  8754. }, float_pos={
  8755. [5] = { {
  8756. id = 1002
  8757. }, "NW", 1, 1, 1, true },
  8758. [6] = { {
  8759. id = 1003
  8760. }, "NW", 1, 0, 0, true }
  8761. }}
  8762. else
  8763. screen:expect([[
  8764. {1:---} |
  8765. {1:-^l-}{0: }|
  8766. {1:-o-}{0: }|
  8767. {1: n }{0: }|
  8768. {1: }{0: }|
  8769. {0:~ }|
  8770. |
  8771. ]])
  8772. end
  8773. end)
  8774. it("correctly orders multiple opened floats (current last)", function()
  8775. local buf = meths.create_buf(false,false)
  8776. local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
  8777. meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
  8778. if multigrid then
  8779. screen:expect{grid=[[
  8780. ## grid 1
  8781. [2:----------------------------------------]|
  8782. [2:----------------------------------------]|
  8783. [2:----------------------------------------]|
  8784. [2:----------------------------------------]|
  8785. [2:----------------------------------------]|
  8786. [2:----------------------------------------]|
  8787. [3:----------------------------------------]|
  8788. ## grid 2
  8789. ^ |
  8790. {0:~ }|
  8791. {0:~ }|
  8792. {0:~ }|
  8793. {0:~ }|
  8794. {0:~ }|
  8795. ## grid 3
  8796. |
  8797. ## grid 4
  8798. {7: }|
  8799. {7:~ }|
  8800. ]], float_pos={
  8801. [4] = { { id = 1001 }, "NW", 1, 2, 5, true };
  8802. }, win_viewport={
  8803. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  8804. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  8805. }}
  8806. else
  8807. screen:expect{grid=[[
  8808. ^ |
  8809. {0:~ }|
  8810. {0:~ }{7: }{0: }|
  8811. {0:~ }{7:~ }{0: }|
  8812. {0:~ }|
  8813. {0:~ }|
  8814. |
  8815. ]]}
  8816. end
  8817. exec_lua [[
  8818. local buf = vim.api.nvim_create_buf(false,false)
  8819. local win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8})
  8820. vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal")
  8821. buf = vim.api.nvim_create_buf(false,false)
  8822. win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10})
  8823. vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search")
  8824. ]]
  8825. if multigrid then
  8826. screen:expect{grid=[[
  8827. ## grid 1
  8828. [2:----------------------------------------]|
  8829. [2:----------------------------------------]|
  8830. [2:----------------------------------------]|
  8831. [2:----------------------------------------]|
  8832. [2:----------------------------------------]|
  8833. [2:----------------------------------------]|
  8834. [3:----------------------------------------]|
  8835. ## grid 2
  8836. |
  8837. {0:~ }|
  8838. {0:~ }|
  8839. {0:~ }|
  8840. {0:~ }|
  8841. {0:~ }|
  8842. ## grid 3
  8843. |
  8844. ## grid 4
  8845. {7: }|
  8846. {7:~ }|
  8847. ## grid 5
  8848. {1: }|
  8849. {1:~ }|
  8850. ## grid 6
  8851. {17:^ }|
  8852. {17:~ }|
  8853. ]], float_pos={
  8854. [4] = { { id = 1001 }, "NW", 1, 2, 5, true };
  8855. [5] = { { id = 1002 }, "NW", 1, 3, 8, true };
  8856. [6] = { { id = 1003 }, "NW", 1, 4, 10, true };
  8857. }, win_viewport={
  8858. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0};
  8859. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0};
  8860. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0};
  8861. [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0};
  8862. }}
  8863. else
  8864. screen:expect{grid=[[
  8865. |
  8866. {0:~ }|
  8867. {0:~ }{7: }{0: }|
  8868. {0:~ }{7:~ }{1: }{7: }{0: }|
  8869. {0:~ }{1:~ }{17:^ }{1: }{0: }|
  8870. {0:~ }{17:~ }{0: }|
  8871. |
  8872. ]]}
  8873. end
  8874. end)
  8875. it("correctly orders multiple opened floats (non-current last)", function()
  8876. local buf = meths.create_buf(false,false)
  8877. local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5})
  8878. meths.win_set_option(win, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
  8879. if multigrid then
  8880. screen:expect{grid=[[
  8881. ## grid 1
  8882. [2:----------------------------------------]|
  8883. [2:----------------------------------------]|
  8884. [2:----------------------------------------]|
  8885. [2:----------------------------------------]|
  8886. [2:----------------------------------------]|
  8887. [2:----------------------------------------]|
  8888. [3:----------------------------------------]|
  8889. ## grid 2
  8890. ^ |
  8891. {0:~ }|
  8892. {0:~ }|
  8893. {0:~ }|
  8894. {0:~ }|
  8895. {0:~ }|
  8896. ## grid 3
  8897. |
  8898. ## grid 4
  8899. {7: }|
  8900. {7:~ }|
  8901. ]], float_pos={
  8902. [4] = { { id = 1001 }, "NW", 1, 2, 5, true };
  8903. }, win_viewport={
  8904. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  8905. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  8906. }}
  8907. else
  8908. screen:expect{grid=[[
  8909. ^ |
  8910. {0:~ }|
  8911. {0:~ }{7: }{0: }|
  8912. {0:~ }{7:~ }{0: }|
  8913. {0:~ }|
  8914. {0:~ }|
  8915. |
  8916. ]]}
  8917. end
  8918. exec_lua [[
  8919. local buf = vim.api.nvim_create_buf(false,false)
  8920. local win = vim.api.nvim_open_win(buf, true, {relative='editor', width=12, height=2, row=4, col=10})
  8921. vim.api.nvim_win_set_option(win, "winhl", "Normal:Search,EndOfBuffer:Search")
  8922. buf = vim.api.nvim_create_buf(false,false)
  8923. win = vim.api.nvim_open_win(buf, false, {relative='editor', width=16, height=2, row=3, col=8})
  8924. vim.api.nvim_win_set_option(win, "winhl", "EndOfBuffer:Normal")
  8925. ]]
  8926. if multigrid then
  8927. screen:expect{grid=[[
  8928. ## grid 1
  8929. [2:----------------------------------------]|
  8930. [2:----------------------------------------]|
  8931. [2:----------------------------------------]|
  8932. [2:----------------------------------------]|
  8933. [2:----------------------------------------]|
  8934. [2:----------------------------------------]|
  8935. [3:----------------------------------------]|
  8936. ## grid 2
  8937. |
  8938. {0:~ }|
  8939. {0:~ }|
  8940. {0:~ }|
  8941. {0:~ }|
  8942. {0:~ }|
  8943. ## grid 3
  8944. |
  8945. ## grid 4
  8946. {7: }|
  8947. {7:~ }|
  8948. ## grid 5
  8949. {17:^ }|
  8950. {17:~ }|
  8951. ## grid 6
  8952. {1: }|
  8953. {1:~ }|
  8954. ]], float_pos={
  8955. [4] = { { id = 1001 }, "NW", 1, 2, 5, true };
  8956. [5] = { { id = 1002 }, "NW", 1, 4, 10, true };
  8957. [6] = { { id = 1003 }, "NW", 1, 3, 8, true };
  8958. }, win_viewport={
  8959. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  8960. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  8961. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  8962. [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  8963. }}
  8964. else
  8965. screen:expect{grid=[[
  8966. |
  8967. {0:~ }|
  8968. {0:~ }{7: }{0: }|
  8969. {0:~ }{7:~ }{1: }{7: }{0: }|
  8970. {0:~ }{1:~ }{17:^ }{1: }{0: }|
  8971. {0:~ }{17:~ }{0: }|
  8972. |
  8973. ]]}
  8974. end
  8975. end)
  8976. it('can use z-index', function()
  8977. local buf = meths.create_buf(false,false)
  8978. local win1 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=1, col=5, zindex=30})
  8979. meths.win_set_option(win1, "winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg")
  8980. local win2 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=6, zindex=50})
  8981. meths.win_set_option(win2, "winhl", "Normal:Search,EndOfBuffer:Search")
  8982. local win3 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=3, col=7, zindex=40})
  8983. meths.win_set_option(win3, "winhl", "Normal:Question,EndOfBuffer:Question")
  8984. if multigrid then
  8985. screen:expect{grid=[[
  8986. ## grid 1
  8987. [2:----------------------------------------]|
  8988. [2:----------------------------------------]|
  8989. [2:----------------------------------------]|
  8990. [2:----------------------------------------]|
  8991. [2:----------------------------------------]|
  8992. [2:----------------------------------------]|
  8993. [3:----------------------------------------]|
  8994. ## grid 2
  8995. ^ |
  8996. {0:~ }|
  8997. {0:~ }|
  8998. {0:~ }|
  8999. {0:~ }|
  9000. {0:~ }|
  9001. ## grid 3
  9002. |
  9003. ## grid 4
  9004. {7: }|
  9005. {7:~ }|
  9006. {7:~ }|
  9007. ## grid 5
  9008. {17: }|
  9009. {17:~ }|
  9010. {17:~ }|
  9011. ## grid 6
  9012. {8: }|
  9013. {8:~ }|
  9014. {8:~ }|
  9015. ]], float_pos={
  9016. [4] = {{id = 1001}, "NW", 1, 1, 5, true, 30};
  9017. [5] = {{id = 1002}, "NW", 1, 2, 6, true, 50};
  9018. [6] = {{id = 1003}, "NW", 1, 3, 7, true, 40};
  9019. }, win_viewport={
  9020. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9021. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9022. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9023. [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9024. }}
  9025. else
  9026. screen:expect{grid=[[
  9027. ^ |
  9028. {0:~ }{7: }{0: }|
  9029. {0:~ }{7:~}{17: }{0: }|
  9030. {0:~ }{7:~}{17:~ }{8: }{0: }|
  9031. {0:~ }{17:~ }{8: }{0: }|
  9032. {0:~ }{8:~ }{0: }|
  9033. |
  9034. ]]}
  9035. end
  9036. end)
  9037. it('can use winbar', function()
  9038. local buf = meths.create_buf(false,false)
  9039. local win1 = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5})
  9040. meths.win_set_option(win1, 'winbar', 'floaty bar')
  9041. if multigrid then
  9042. screen:expect{grid=[[
  9043. ## grid 1
  9044. [2:----------------------------------------]|
  9045. [2:----------------------------------------]|
  9046. [2:----------------------------------------]|
  9047. [2:----------------------------------------]|
  9048. [2:----------------------------------------]|
  9049. [2:----------------------------------------]|
  9050. [3:----------------------------------------]|
  9051. ## grid 2
  9052. ^ |
  9053. {0:~ }|
  9054. {0:~ }|
  9055. {0:~ }|
  9056. {0:~ }|
  9057. {0:~ }|
  9058. ## grid 3
  9059. |
  9060. ## grid 4
  9061. {3:floaty bar }|
  9062. {1: }|
  9063. {2:~ }|
  9064. ]], float_pos={
  9065. [4] = {{id = 1001}, "NW", 1, 1, 5, true, 50};
  9066. }, win_viewport={
  9067. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9068. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9069. }}
  9070. else
  9071. screen:expect{grid=[[
  9072. ^ |
  9073. {0:~ }{3:floaty bar }{0: }|
  9074. {0:~ }{1: }{0: }|
  9075. {0:~ }{2:~ }{0: }|
  9076. {0:~ }|
  9077. {0:~ }|
  9078. |
  9079. ]]}
  9080. end
  9081. -- resize and add a border
  9082. meths.win_set_config(win1, {relative='editor', width=15, height=4, row=0, col=4, border = 'single'})
  9083. if multigrid then
  9084. screen:expect{grid=[[
  9085. ## grid 1
  9086. [2:----------------------------------------]|
  9087. [2:----------------------------------------]|
  9088. [2:----------------------------------------]|
  9089. [2:----------------------------------------]|
  9090. [2:----------------------------------------]|
  9091. [2:----------------------------------------]|
  9092. [3:----------------------------------------]|
  9093. ## grid 2
  9094. ^ |
  9095. {0:~ }|
  9096. {0:~ }|
  9097. {0:~ }|
  9098. {0:~ }|
  9099. {0:~ }|
  9100. ## grid 3
  9101. |
  9102. ## grid 4
  9103. {5:┌───────────────┐}|
  9104. {5:│}{3:floaty bar }{5:│}|
  9105. {5:│}{1: }{5:│}|
  9106. {5:│}{2:~ }{5:│}|
  9107. {5:│}{2:~ }{5:│}|
  9108. {5:└───────────────┘}|
  9109. ]], float_pos={
  9110. [4] = {{id = 1001}, "NW", 1, 0, 4, true, 50};
  9111. }, win_viewport={
  9112. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9113. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9114. }}
  9115. else
  9116. screen:expect{grid=[[
  9117. ^ {5:┌───────────────┐} |
  9118. {0:~ }{5:│}{3:floaty bar }{5:│}{0: }|
  9119. {0:~ }{5:│}{1: }{5:│}{0: }|
  9120. {0:~ }{5:│}{2:~ }{5:│}{0: }|
  9121. {0:~ }{5:│}{2:~ }{5:│}{0: }|
  9122. {0:~ }{5:└───────────────┘}{0: }|
  9123. |
  9124. ]]}
  9125. end
  9126. end)
  9127. it('it can be resized with messages and cmdheight=0 #20106', function()
  9128. screen:try_resize(40,9)
  9129. command 'set cmdheight=0'
  9130. local buf = meths.create_buf(false,true)
  9131. local win = meths.open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=9, col=0, style='minimal', border="single", noautocmd=true})
  9132. if multigrid then
  9133. screen:expect{grid=[[
  9134. ## grid 1
  9135. [2:----------------------------------------]|
  9136. [2:----------------------------------------]|
  9137. [2:----------------------------------------]|
  9138. [2:----------------------------------------]|
  9139. [2:----------------------------------------]|
  9140. [2:----------------------------------------]|
  9141. [2:----------------------------------------]|
  9142. [2:----------------------------------------]|
  9143. [2:----------------------------------------]|
  9144. ## grid 2
  9145. ^ |
  9146. {0:~ }|
  9147. {0:~ }|
  9148. {0:~ }|
  9149. {0:~ }|
  9150. {0:~ }|
  9151. {0:~ }|
  9152. {0:~ }|
  9153. {0:~ }|
  9154. ## grid 3
  9155. ## grid 5
  9156. {5:┌────────────────────────────────────────┐}|
  9157. {5:│}{1: }{5:│}|
  9158. {5:│}{1: }{5:│}|
  9159. {5:│}{1: }{5:│}|
  9160. {5:│}{1: }{5:│}|
  9161. {5:└────────────────────────────────────────┘}|
  9162. ]], float_pos={
  9163. [5] = {{id = 1002}, "SW", 1, 9, 0, true, 50};
  9164. }, win_viewport={
  9165. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9166. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9167. }}
  9168. else
  9169. screen:expect{grid=[[
  9170. ^ |
  9171. {0:~ }|
  9172. {0:~ }|
  9173. {5:┌──────────────────────────────────────┐}|
  9174. {5:│}{1: }{5:│}|
  9175. {5:│}{1: }{5:│}|
  9176. {5:│}{1: }{5:│}|
  9177. {5:│}{1: }{5:│}|
  9178. {5:└──────────────────────────────────────┘}|
  9179. ]]}
  9180. end
  9181. exec_lua([[
  9182. local win = ...
  9183. vim.api.nvim_win_set_height(win, 2)
  9184. vim.api.nvim_echo({ { "" } }, false, {})
  9185. ]], win)
  9186. if multigrid then
  9187. screen:expect{grid=[[
  9188. ## grid 1
  9189. [2:----------------------------------------]|
  9190. [2:----------------------------------------]|
  9191. [2:----------------------------------------]|
  9192. [2:----------------------------------------]|
  9193. [2:----------------------------------------]|
  9194. [2:----------------------------------------]|
  9195. [2:----------------------------------------]|
  9196. [2:----------------------------------------]|
  9197. [2:----------------------------------------]|
  9198. ## grid 2
  9199. ^ |
  9200. {0:~ }|
  9201. {0:~ }|
  9202. {0:~ }|
  9203. {0:~ }|
  9204. {0:~ }|
  9205. {0:~ }|
  9206. {0:~ }|
  9207. {0:~ }|
  9208. ## grid 3
  9209. ## grid 5
  9210. {5:┌────────────────────────────────────────┐}|
  9211. {5:│}{1: }{5:│}|
  9212. {5:│}{1: }{5:│}|
  9213. {5:└────────────────────────────────────────┘}|
  9214. ]], float_pos={
  9215. [5] = {{id = 1002}, "SW", 1, 9, 0, true, 50};
  9216. }, win_viewport={
  9217. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9218. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9219. }}
  9220. else
  9221. screen:expect{grid=[[
  9222. ^ |
  9223. {0:~ }|
  9224. {0:~ }|
  9225. {0:~ }|
  9226. {0:~ }|
  9227. {5:┌──────────────────────────────────────┐}|
  9228. {5:│}{1: }{5:│}|
  9229. {5:│}{1: }{5:│}|
  9230. {5:└──────────────────────────────────────┘}|
  9231. ]]}
  9232. end
  9233. meths.win_close(win, true)
  9234. if multigrid then
  9235. screen:expect{grid=[[
  9236. ## grid 1
  9237. [2:----------------------------------------]|
  9238. [2:----------------------------------------]|
  9239. [2:----------------------------------------]|
  9240. [2:----------------------------------------]|
  9241. [2:----------------------------------------]|
  9242. [2:----------------------------------------]|
  9243. [2:----------------------------------------]|
  9244. [2:----------------------------------------]|
  9245. [2:----------------------------------------]|
  9246. ## grid 2
  9247. ^ |
  9248. {0:~ }|
  9249. {0:~ }|
  9250. {0:~ }|
  9251. {0:~ }|
  9252. {0:~ }|
  9253. {0:~ }|
  9254. {0:~ }|
  9255. {0:~ }|
  9256. ## grid 3
  9257. ]], win_viewport={
  9258. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9259. }}
  9260. else
  9261. screen:expect{grid=[[
  9262. ^ |
  9263. {0:~ }|
  9264. {0:~ }|
  9265. {0:~ }|
  9266. {0:~ }|
  9267. {0:~ }|
  9268. {0:~ }|
  9269. {0:~ }|
  9270. {0:~ }|
  9271. ]]}
  9272. end
  9273. end)
  9274. it('it can be resized with messages and cmdheight=1', function()
  9275. screen:try_resize(40,9)
  9276. local buf = meths.create_buf(false,true)
  9277. local win = meths.open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=8, col=0, style='minimal', border="single", noautocmd=true})
  9278. if multigrid then
  9279. screen:expect{grid=[[
  9280. ## grid 1
  9281. [2:----------------------------------------]|
  9282. [2:----------------------------------------]|
  9283. [2:----------------------------------------]|
  9284. [2:----------------------------------------]|
  9285. [2:----------------------------------------]|
  9286. [2:----------------------------------------]|
  9287. [2:----------------------------------------]|
  9288. [2:----------------------------------------]|
  9289. [3:----------------------------------------]|
  9290. ## grid 2
  9291. ^ |
  9292. {0:~ }|
  9293. {0:~ }|
  9294. {0:~ }|
  9295. {0:~ }|
  9296. {0:~ }|
  9297. {0:~ }|
  9298. {0:~ }|
  9299. ## grid 3
  9300. |
  9301. ## grid 5
  9302. {5:┌────────────────────────────────────────┐}|
  9303. {5:│}{1: }{5:│}|
  9304. {5:│}{1: }{5:│}|
  9305. {5:│}{1: }{5:│}|
  9306. {5:│}{1: }{5:│}|
  9307. {5:└────────────────────────────────────────┘}|
  9308. ]], float_pos={
  9309. [5] = {{id = 1002}, "SW", 1, 8, 0, true, 50};
  9310. }, win_viewport={
  9311. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9312. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9313. }}
  9314. else
  9315. screen:expect{grid=[[
  9316. ^ |
  9317. {0:~ }|
  9318. {5:┌──────────────────────────────────────┐}|
  9319. {5:│}{1: }{5:│}|
  9320. {5:│}{1: }{5:│}|
  9321. {5:│}{1: }{5:│}|
  9322. {5:│}{1: }{5:│}|
  9323. {5:└──────────────────────────────────────┘}|
  9324. |
  9325. ]]}
  9326. end
  9327. exec_lua([[
  9328. -- echo prompt is blocking, so schedule
  9329. local win = ...
  9330. vim.schedule(function()
  9331. vim.api.nvim_win_set_height(win, 2)
  9332. vim.api.nvim_echo({ { "\n" } }, false, {})
  9333. end)
  9334. ]], win)
  9335. if multigrid then
  9336. screen:expect{grid=[[
  9337. ## grid 1
  9338. [2:----------------------------------------]|
  9339. [2:----------------------------------------]|
  9340. [2:----------------------------------------]|
  9341. [2:----------------------------------------]|
  9342. [2:----------------------------------------]|
  9343. [2:----------------------------------------]|
  9344. [2:----------------------------------------]|
  9345. [3:----------------------------------------]|
  9346. [3:----------------------------------------]|
  9347. ## grid 2
  9348. |
  9349. {0:~ }|
  9350. {0:~ }|
  9351. {0:~ }|
  9352. {0:~ }|
  9353. {0:~ }|
  9354. {0:~ }|
  9355. {0:~ }|
  9356. ## grid 3
  9357. |
  9358. {8:Press ENTER or type command to continue}^ |
  9359. ## grid 5
  9360. {5:┌────────────────────────────────────────┐}|
  9361. {5:│}{1: }{5:│}|
  9362. {5:│}{1: }{5:│}|
  9363. {5:│}{1: }{5:│}|
  9364. {5:│}{1: }{5:│}|
  9365. {5:└────────────────────────────────────────┘}|
  9366. ]], float_pos={
  9367. [5] = {{id = 1002}, "SW", 1, 8, 0, true, 50};
  9368. }, win_viewport={
  9369. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9370. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9371. }}
  9372. else
  9373. screen:expect{grid=[[
  9374. |
  9375. {0:~ }|
  9376. {5:┌──────────────────────────────────────┐}|
  9377. {5:│}{1: }{5:│}|
  9378. {5:│}{1: }{5:│}|
  9379. {5:│}{1: }{5:│}|
  9380. {4: }|
  9381. |
  9382. {8:Press ENTER or type command to continue}^ |
  9383. ]]}
  9384. end
  9385. feed('<cr>')
  9386. if multigrid then
  9387. screen:expect{grid=[[
  9388. ## grid 1
  9389. [2:----------------------------------------]|
  9390. [2:----------------------------------------]|
  9391. [2:----------------------------------------]|
  9392. [2:----------------------------------------]|
  9393. [2:----------------------------------------]|
  9394. [2:----------------------------------------]|
  9395. [2:----------------------------------------]|
  9396. [2:----------------------------------------]|
  9397. [3:----------------------------------------]|
  9398. ## grid 2
  9399. ^ |
  9400. {0:~ }|
  9401. {0:~ }|
  9402. {0:~ }|
  9403. {0:~ }|
  9404. {0:~ }|
  9405. {0:~ }|
  9406. {0:~ }|
  9407. ## grid 3
  9408. |
  9409. ## grid 5
  9410. {5:┌────────────────────────────────────────┐}|
  9411. {5:│}{1: }{5:│}|
  9412. {5:│}{1: }{5:│}|
  9413. {5:└────────────────────────────────────────┘}|
  9414. ]], float_pos={
  9415. [5] = {{id = 1002}, "SW", 1, 8, 0, true, 50};
  9416. }, win_viewport={
  9417. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9418. [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9419. }}
  9420. else
  9421. screen:expect{grid=[[
  9422. ^ |
  9423. {0:~ }|
  9424. {0:~ }|
  9425. {0:~ }|
  9426. {5:┌──────────────────────────────────────┐}|
  9427. {5:│}{1: }{5:│}|
  9428. {5:│}{1: }{5:│}|
  9429. {5:└──────────────────────────────────────┘}|
  9430. |
  9431. ]]}
  9432. end
  9433. meths.win_close(win, true)
  9434. if multigrid then
  9435. screen:expect{grid=[[
  9436. ## grid 1
  9437. [2:----------------------------------------]|
  9438. [2:----------------------------------------]|
  9439. [2:----------------------------------------]|
  9440. [2:----------------------------------------]|
  9441. [2:----------------------------------------]|
  9442. [2:----------------------------------------]|
  9443. [2:----------------------------------------]|
  9444. [2:----------------------------------------]|
  9445. [3:----------------------------------------]|
  9446. ## grid 2
  9447. ^ |
  9448. {0:~ }|
  9449. {0:~ }|
  9450. {0:~ }|
  9451. {0:~ }|
  9452. {0:~ }|
  9453. {0:~ }|
  9454. {0:~ }|
  9455. ## grid 3
  9456. |
  9457. ]], win_viewport={
  9458. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9459. }}
  9460. else
  9461. screen:expect{grid=[[
  9462. ^ |
  9463. {0:~ }|
  9464. {0:~ }|
  9465. {0:~ }|
  9466. {0:~ }|
  9467. {0:~ }|
  9468. {0:~ }|
  9469. {0:~ }|
  9470. |
  9471. ]]}
  9472. end
  9473. end)
  9474. describe('no crash after moving and closing float window #21547', function()
  9475. local function test_float_move_close(cmd)
  9476. local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10}
  9477. meths.open_win(meths.create_buf(false, false), true, float_opts)
  9478. if multigrid then
  9479. screen:expect({float_pos = {[4] = {{id = 1001}, 'NW', 1, 1, 1, true}}})
  9480. end
  9481. command(cmd)
  9482. exec_lua([[
  9483. vim.api.nvim_win_set_config(0, {relative = 'editor', row = 2, col = 2})
  9484. vim.api.nvim_win_close(0, {})
  9485. vim.api.nvim_echo({{''}}, false, {})
  9486. ]])
  9487. if multigrid then
  9488. screen:expect({float_pos = {}})
  9489. end
  9490. assert_alive()
  9491. end
  9492. it('if WinClosed autocommand flushes UI', function()
  9493. test_float_move_close('autocmd WinClosed * ++once redraw')
  9494. end)
  9495. it('if closing buffer flushes UI', function()
  9496. test_float_move_close('autocmd BufWinLeave * ++once redraw')
  9497. end)
  9498. end)
  9499. it(':sleep cursor placement #22639', function()
  9500. local float_opts = {relative = 'editor', row = 1, col = 1, width = 4, height = 3}
  9501. local win = meths.open_win(meths.create_buf(false, false), true, float_opts)
  9502. feed('iab<CR>cd<Esc>')
  9503. feed(':sleep 100')
  9504. if multigrid then
  9505. screen:expect{grid=[[
  9506. ## grid 1
  9507. [2:----------------------------------------]|
  9508. [2:----------------------------------------]|
  9509. [2:----------------------------------------]|
  9510. [2:----------------------------------------]|
  9511. [2:----------------------------------------]|
  9512. [2:----------------------------------------]|
  9513. [3:----------------------------------------]|
  9514. ## grid 2
  9515. |
  9516. {0:~ }|
  9517. {0:~ }|
  9518. {0:~ }|
  9519. {0:~ }|
  9520. {0:~ }|
  9521. ## grid 3
  9522. :sleep 100^ |
  9523. ## grid 4
  9524. {1:ab }|
  9525. {1:cd }|
  9526. {2:~ }|
  9527. ]], float_pos={
  9528. [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50};
  9529. }, win_viewport={
  9530. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9531. [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0};
  9532. }}
  9533. else
  9534. screen:expect{grid=[[
  9535. |
  9536. {0:~}{1:ab }{0: }|
  9537. {0:~}{1:cd }{0: }|
  9538. {0:~}{2:~ }{0: }|
  9539. {0:~ }|
  9540. {0:~ }|
  9541. :sleep 100^ |
  9542. ]]}
  9543. end
  9544. feed('<CR>')
  9545. if multigrid then
  9546. screen:expect{grid=[[
  9547. ## grid 1
  9548. [2:----------------------------------------]|
  9549. [2:----------------------------------------]|
  9550. [2:----------------------------------------]|
  9551. [2:----------------------------------------]|
  9552. [2:----------------------------------------]|
  9553. [2:----------------------------------------]|
  9554. [3:----------------------------------------]|
  9555. ## grid 2
  9556. |
  9557. {0:~ }|
  9558. {0:~ }|
  9559. {0:~ }|
  9560. {0:~ }|
  9561. {0:~ }|
  9562. ## grid 3
  9563. :sleep 100 |
  9564. ## grid 4
  9565. {1:ab }|
  9566. {1:c^d }|
  9567. {2:~ }|
  9568. ]], float_pos={
  9569. [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50};
  9570. }, win_viewport={
  9571. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9572. [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0};
  9573. }}
  9574. else
  9575. screen:expect{grid=[[
  9576. |
  9577. {0:~}{1:ab }{0: }|
  9578. {0:~}{1:c^d }{0: }|
  9579. {0:~}{2:~ }{0: }|
  9580. {0:~ }|
  9581. {0:~ }|
  9582. :sleep 100 |
  9583. ]]}
  9584. end
  9585. feed('<C-C>')
  9586. screen:expect_unchanged()
  9587. meths.win_set_config(win, {border = 'single'})
  9588. feed(':sleep 100')
  9589. if multigrid then
  9590. screen:expect{grid=[[
  9591. ## grid 1
  9592. [2:----------------------------------------]|
  9593. [2:----------------------------------------]|
  9594. [2:----------------------------------------]|
  9595. [2:----------------------------------------]|
  9596. [2:----------------------------------------]|
  9597. [2:----------------------------------------]|
  9598. [3:----------------------------------------]|
  9599. ## grid 2
  9600. |
  9601. {0:~ }|
  9602. {0:~ }|
  9603. {0:~ }|
  9604. {0:~ }|
  9605. {0:~ }|
  9606. ## grid 3
  9607. :sleep 100^ |
  9608. ## grid 4
  9609. {5:┌────┐}|
  9610. {5:│}{1:ab }{5:│}|
  9611. {5:│}{1:cd }{5:│}|
  9612. {5:│}{2:~ }{5:│}|
  9613. {5:└────┘}|
  9614. ]], float_pos={
  9615. [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50};
  9616. }, win_viewport={
  9617. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9618. [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0};
  9619. }}
  9620. else
  9621. screen:expect{grid=[[
  9622. |
  9623. {0:~}{5:┌────┐}{0: }|
  9624. {0:~}{5:│}{1:ab }{5:│}{0: }|
  9625. {0:~}{5:│}{1:cd }{5:│}{0: }|
  9626. {0:~}{5:│}{2:~ }{5:│}{0: }|
  9627. {0:~}{5:└────┘}{0: }|
  9628. :sleep 100^ |
  9629. ]]}
  9630. end
  9631. feed('<CR>')
  9632. if multigrid then
  9633. screen:expect{grid=[[
  9634. ## grid 1
  9635. [2:----------------------------------------]|
  9636. [2:----------------------------------------]|
  9637. [2:----------------------------------------]|
  9638. [2:----------------------------------------]|
  9639. [2:----------------------------------------]|
  9640. [2:----------------------------------------]|
  9641. [3:----------------------------------------]|
  9642. ## grid 2
  9643. |
  9644. {0:~ }|
  9645. {0:~ }|
  9646. {0:~ }|
  9647. {0:~ }|
  9648. {0:~ }|
  9649. ## grid 3
  9650. :sleep 100 |
  9651. ## grid 4
  9652. {5:┌────┐}|
  9653. {5:│}{1:ab }{5:│}|
  9654. {5:│}{1:c^d }{5:│}|
  9655. {5:│}{2:~ }{5:│}|
  9656. {5:└────┘}|
  9657. ]], float_pos={
  9658. [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50};
  9659. }, win_viewport={
  9660. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9661. [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0};
  9662. }}
  9663. else
  9664. screen:expect{grid=[[
  9665. |
  9666. {0:~}{5:┌────┐}{0: }|
  9667. {0:~}{5:│}{1:ab }{5:│}{0: }|
  9668. {0:~}{5:│}{1:c^d }{5:│}{0: }|
  9669. {0:~}{5:│}{2:~ }{5:│}{0: }|
  9670. {0:~}{5:└────┘}{0: }|
  9671. :sleep 100 |
  9672. ]]}
  9673. end
  9674. feed('<C-C>')
  9675. screen:expect_unchanged()
  9676. command('setlocal winbar=foo')
  9677. feed(':sleep 100')
  9678. if multigrid then
  9679. screen:expect{grid=[[
  9680. ## grid 1
  9681. [2:----------------------------------------]|
  9682. [2:----------------------------------------]|
  9683. [2:----------------------------------------]|
  9684. [2:----------------------------------------]|
  9685. [2:----------------------------------------]|
  9686. [2:----------------------------------------]|
  9687. [3:----------------------------------------]|
  9688. ## grid 2
  9689. |
  9690. {0:~ }|
  9691. {0:~ }|
  9692. {0:~ }|
  9693. {0:~ }|
  9694. {0:~ }|
  9695. ## grid 3
  9696. :sleep 100^ |
  9697. ## grid 4
  9698. {5:┌────┐}|
  9699. {5:│}{3:foo }{5:│}|
  9700. {5:│}{1:ab }{5:│}|
  9701. {5:│}{1:cd }{5:│}|
  9702. {5:└────┘}|
  9703. ]], float_pos={
  9704. [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50};
  9705. }, win_viewport={
  9706. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9707. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0};
  9708. }}
  9709. else
  9710. screen:expect{grid=[[
  9711. |
  9712. {0:~}{5:┌────┐}{0: }|
  9713. {0:~}{5:│}{3:foo }{5:│}{0: }|
  9714. {0:~}{5:│}{1:ab }{5:│}{0: }|
  9715. {0:~}{5:│}{1:cd }{5:│}{0: }|
  9716. {0:~}{5:└────┘}{0: }|
  9717. :sleep 100^ |
  9718. ]]}
  9719. end
  9720. feed('<CR>')
  9721. if multigrid then
  9722. screen:expect{grid=[[
  9723. ## grid 1
  9724. [2:----------------------------------------]|
  9725. [2:----------------------------------------]|
  9726. [2:----------------------------------------]|
  9727. [2:----------------------------------------]|
  9728. [2:----------------------------------------]|
  9729. [2:----------------------------------------]|
  9730. [3:----------------------------------------]|
  9731. ## grid 2
  9732. |
  9733. {0:~ }|
  9734. {0:~ }|
  9735. {0:~ }|
  9736. {0:~ }|
  9737. {0:~ }|
  9738. ## grid 3
  9739. :sleep 100 |
  9740. ## grid 4
  9741. {5:┌────┐}|
  9742. {5:│}{3:foo }{5:│}|
  9743. {5:│}{1:ab }{5:│}|
  9744. {5:│}{1:c^d }{5:│}|
  9745. {5:└────┘}|
  9746. ]], float_pos={
  9747. [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50};
  9748. }, win_viewport={
  9749. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9750. [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0};
  9751. }}
  9752. else
  9753. screen:expect{grid=[[
  9754. |
  9755. {0:~}{5:┌────┐}{0: }|
  9756. {0:~}{5:│}{3:foo }{5:│}{0: }|
  9757. {0:~}{5:│}{1:ab }{5:│}{0: }|
  9758. {0:~}{5:│}{1:c^d }{5:│}{0: }|
  9759. {0:~}{5:└────┘}{0: }|
  9760. :sleep 100 |
  9761. ]]}
  9762. end
  9763. feed('<C-C>')
  9764. screen:expect_unchanged()
  9765. end)
  9766. it('with rightleft and border #22640', function()
  9767. local float_opts = {relative='editor', width=5, height=3, row=1, col=1, border='single'}
  9768. meths.open_win(meths.create_buf(false, false), true, float_opts)
  9769. command('setlocal rightleft')
  9770. feed('iabc<CR>def<Esc>')
  9771. if multigrid then
  9772. screen:expect{grid=[[
  9773. ## grid 1
  9774. [2:----------------------------------------]|
  9775. [2:----------------------------------------]|
  9776. [2:----------------------------------------]|
  9777. [2:----------------------------------------]|
  9778. [2:----------------------------------------]|
  9779. [2:----------------------------------------]|
  9780. [3:----------------------------------------]|
  9781. ## grid 2
  9782. |
  9783. {0:~ }|
  9784. {0:~ }|
  9785. {0:~ }|
  9786. {0:~ }|
  9787. {0:~ }|
  9788. ## grid 3
  9789. |
  9790. ## grid 4
  9791. {5:┌─────┐}|
  9792. {5:│}{1: cba}{5:│}|
  9793. {5:│}{1: ^fed}{5:│}|
  9794. {5:│}{2: ~}{5:│}|
  9795. {5:└─────┘}|
  9796. ]], float_pos={
  9797. [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50};
  9798. }, win_viewport={
  9799. [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0};
  9800. [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 2, sum_scroll_delta = 0};
  9801. }}
  9802. else
  9803. screen:expect{grid=[[
  9804. |
  9805. {0:~}{5:┌─────┐}{0: }|
  9806. {0:~}{5:│}{1: cba}{5:│}{0: }|
  9807. {0:~}{5:│}{1: ^fed}{5:│}{0: }|
  9808. {0:~}{5:│}{2: ~}{5:│}{0: }|
  9809. {0:~}{5:└─────┘}{0: }|
  9810. |
  9811. ]]}
  9812. end
  9813. end)
  9814. end
  9815. describe('with ext_multigrid', function()
  9816. with_ext_multigrid(true)
  9817. end)
  9818. describe('without ext_multigrid', function()
  9819. with_ext_multigrid(false)
  9820. end)
  9821. end)